#include <stdio.h>
static int fact(int n, int m) {
int result = 1;
int i;
for (i = 1; i <= n; i++)
result = (result * i) % m;
return result;
}
int main() {
int i;
for (i = 1; i <= 1000; i++)
if (fact (i - 1, i) == i - 1)
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgpzdGF0aWMgaW50IGZhY3QoaW50IG4sIGludCBtKSB7CiAgaW50IHJlc3VsdCA9IDE7CiAgaW50IGk7CiAgZm9yIChpID0gMTsgaSA8PSBuOyBpKyspCiAgICByZXN1bHQgPSAocmVzdWx0ICogaSkgJSBtOwogIHJldHVybiByZXN1bHQ7Cn0KCmludCBtYWluKCkgewogIGludCBpOwogIGZvciAoaSA9IDE7IGkgPD0gMTAwMDsgaSsrKQogICAgaWYgKGZhY3QgKGkgLSAxLCBpKSA9PSBpIC0gMSkKICAgICAgcHJpbnRmICgiJWRcbiIsIGkpOwp9