/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int n;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	while(scanf("%d", &n) == 1){
		if(n % 2 == 0){
			printf("2^? mod %d = 1\n", n);
		}else{
			int t = 1, flag = 0;
			for (int i = 1; i < 5000; i++){
				t *= 2;
				if(t % n == 1){
					printf("2^%d mod %d = 1\n", i, n);
					flag = 1;
					break;
				}else{
					t %= n;
				}
			}
			if(!flag){
				printf("2^? mod %d = 1\n", n);
			}
		}
	}

	return 0;
}
/**/