/* Finds intersection point given two lines
 Note that by duality this also solves the problem *Find line passing through two points* */

p = 37
A = 17
B = 23
C = 29
D = 3
E = 3
F = 0		
a = 0
b = 0
c = 1
match = 0
{
while(a<=p-1 && match!=1,
while(b<=p-1 && match!=1,
while(c<=p-1 && match!=1,
if((A*a + B*b + C*c)%p == 0 && (D*a + E*b + F*c)%p == 0,
                                match = 1;
                                print("(",a,",",b,",",c,")")
   );
   c++;
);b++;c = 0);
   a++;
   b = 0;
   c = 0
);
}