p = 7;

P = 1;
Q = 2;
R = 3;

found = 0;

{for(a = 0, p - 1,
   for(b = 0, p - 1,
     for(c = 0, p - 1,
       for(d = 0, p - 1,
         if( (c + d*P)%p == 0 &&
             (a + b*Q)%p == 0 &&
             (a + b*R)%p == (c + d*R)%p &&
             (a != 0 || b != 0 || c != 0 || d != 0) &&
             found == 0,
             
             m = matrix(2,2);
             m[1,1] = a; m[1,2] = b; m[2,1] = c; m[2,2] = d;
             print(m);
             found = 1
         )
       )
     )
   )
 )
}