#male(ram).
#male(ajay).
#male(roy).
#male(ravi).

#female(seeta).
#female(priya).
#female(nisha).
#female(jenny).

#parent(ram,seeta,ajay).
#parent(ram,seeta,nisha).
#parent(ajay,priya,roy).
#parent(ravi,nisha,jenny).

#father(X,Y) :- parent(X,Z,Y).
#mother(X,Y) :- parent(Z,X,Y).

#grandfather(X,Y) :- male(X), father(X,Z), father(Z,Y).
#grandmother(X,Y) :- female(X), mother(X,Z), father(Z,Y).