#include #include using namespace std; using ll = long long int; int main() { ll N, K; cin >> N >> K; ll amari = N % 6; K %= 6; for (int i = 0; i < K; i++) { amari *= amari; amari %= 6; } amari %= 6; cout << amari << endl; string s = "285714"; cout << s[(amari-1)%6] << endl; system("pause"); return 0; }