#include<iostream>
#include<vector>
using namespace std;
vector<vector<int>> x(50, vector<int>(50, 0));
int Div[51],K;
inline int solve() {
int q = 1, p = 0;
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 50; j++) {
if (x[i][j] == 1)p += q;
q *= 2; q %= K; p %= K;
}
}
return p;
}
inline int Query(int i1, int i2, int i3, int i4) {
cout << "? " << i1 << ' ' << i2 << ' ' << i3 << ' ' << i4 << endl;
int Va; cin >> Va;
return Va;
}
inline void solve2(int row, int col, int p1) {
int i = row, j = col;
if (p1 == 0) { x[i][j] = 0; x[i][j + 1] = 0; x[i + 1][j] = 0; x[i + 1][j + 1] = 0; }
else if (p1 == 4) { x[i][j] = 1; x[i][j + 1] = 1; x[i + 1][j] = 1; x[i + 1][j + 1] = 1; }
else {
int p2 = Query(i, j, i, j + 1), p3 = p1 - p2;
if (p2 == 0) { x[i][j] = 0; x[i][j + 1] = 0; }
if (p2 == 2) { x[i][j] = 1; x[i][j + 1] = 1; }
if (p3 == 0) { x[i + 1][j] = 0; x[i + 1][j + 1] = 0; }
if (p3 == 2) { x[i + 1][j] = 1; x[i + 1][j + 1] = 1; }
if (p2 == 1 && p3 == 1) {
int p4 = Query(i, j, i + 1, j);
if (p4 == 0) { x[i][j] = 0; x[i + 1][j] = 0; x[i][j + 1] = 1; x[i + 1][j + 1] = 1; }
else if (p4 == 2) { x[i][j] = 1; x[i + 1][j] = 1; x[i][j + 1] = 0; x[i + 1][j + 1] = 0; }
else {
int p5 = Query(i, j, i, j); x[i][j] = p5;
x[i + 1][j] = p4 - p5; x[i][j + 1] = p2 - p5; x[i + 1][j + 1] = p3 - x[i + 1][j];
}
}
else {
if (p2 == 1) { x[i][j] = Query(i, j, i, j); x[i][j + 1] = 1 - x[i][j]; }
if (p3 == 1) { x[i + 1][j] = Query(i + 1, j, i + 1, j); x[i + 1][j + 1] = 1 - x[i + 1][j]; }
}
}
}
inline void solve4(int row, int col, int p1) {
int i = row, j = col;
if (p1 == 0)return;
int p2 = Query(i, j, i + 1, j + 3), p3 = p1 - p2;
if (p2 == 0) {}
if (p2 == 8) { for (int I = i + 0; I < i + 2; I++) { for (int J = j + 0; J < j + 4; J++) { x[I][J] = 1; } } }
if (p3 == 0) {}
if (p3 == 8) { for (int I = i + 2; I < i + 4; I++) { for (int J = j + 0; J < j + 4; J++) { x[I][J] = 1; } } }
if (p2 >= 1 && p2 <= 7 && p3 >= 1 && p3 <= 7) {
int p4 = Query(i, j, i + 3, j + 1), p5 = p1 - p4;
if (p4 != 0 && p5 != 0) {
int p10 = Query(i, j, i + 1, j + 1), p11 = p2 - p10;
int p12 = p4 - p10, p13 = p5 - p11;
solve2(i, j, p10); solve2(i, j + 2, p11);
solve2(i + 2, j, p12); solve2(i + 2, j + 2, p13);
}
if (p4 == 0) {
solve2(i, j, 0); solve2(i + 2, j, 0);
solve2(i, j + 2, p2); solve2(i + 2, j + 2, p3);
}
else if (p5 == 0) {
solve2(i, j, p2); solve2(i + 2, j, p3);
solve2(i, j + 2, 0); solve2(i + 2, j + 2, 0);
}
}
else {
if (p2 >= 1 && p2 <= 7) { int p6 = Query(i, j, i + 1, j + 1), p7 = p2 - p6; solve2(i, j, p6); solve2(i, j + 2, p7); }
if (p3 >= 1 && p3 <= 7) { int p8 = Query(i + 2, j, i + 3, j + 1), p9 = p3 - p8; solve2(i + 2, j, p8); solve2(i + 2, j + 2, p9); }
}
}
inline void saiki(int row, int col, int hs, int ws, int p1) {
if (row >= 50 || col >= 50)return;
if (hs == 2 && ws == 2) { solve2(row, col, p1); return; }
if (hs == 4 && ws == 4) { solve4(row, col, p1); return; }
if (hs > ws) {
int E1 = p1;
int EE1, EE2;
if (E1 == hs*ws) { EE1 = ws*Div[hs]; EE2 = ws*(hs - Div[hs]); }
else if (E1 == 0) { EE1 = 0; EE2 = 0; }
else { EE1 = Query(row, col, row + Div[hs] - 1, col + ws - 1); EE2 = E1 - EE1; }
saiki(row, col, Div[hs], ws, EE1);
saiki(row + Div[hs], col, hs - Div[hs], ws, EE2);
}
else {
int E1 = p1;
int EE1, EE2;
if (E1 == hs*ws) { EE1 = hs*Div[ws]; EE2 = hs*(ws - Div[ws]); }
else if (E1 == 0) { EE1 = 0; EE2 = 0; }
else { EE1 = Query(row, col, row + hs - 1, col + Div[ws] - 1); EE2 = E1 - EE1; }
saiki(row, col, hs, Div[ws], EE1);
saiki(row, col + Div[ws], hs, ws - Div[ws], EE2);
}
}
int main() {
int H, W, N; cin >> H >> W >> N>>K;
for (int i = 1; i <= 50; i++) {
if (i > 32)Div[i] = 32;
else if (i > 16)Div[i] = 16;
else if (i > 8)Div[i] = 8;
else if (i > 4)Div[i] = 4;
else if (i > 2)Div[i] = 2;
else if (i > 1)Div[i] = 1;
}
saiki(0, 0, 50, 50, 250);
cout << "! " << solve() << endl;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHZlY3Rvcj4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdmVjdG9yPHZlY3RvcjxpbnQ+PiB4KDUwLCB2ZWN0b3I8aW50Pig1MCwgMCkpOwppbnQgRGl2WzUxXSxLOwppbmxpbmUgaW50IHNvbHZlKCkgewoJaW50IHEgPSAxLCBwID0gMDsKCWZvciAoaW50IGkgPSAwOyBpIDwgNTA7IGkrKykgewoJCWZvciAoaW50IGogPSAwOyBqIDwgNTA7IGorKykgewoJCQlpZiAoeFtpXVtqXSA9PSAxKXAgKz0gcTsKCQkJcSAqPSAyOyBxICU9IEs7IHAgJT0gSzsKCQl9Cgl9CglyZXR1cm4gcDsKfQppbmxpbmUgaW50IFF1ZXJ5KGludCBpMSwgaW50IGkyLCBpbnQgaTMsIGludCBpNCkgewoJY291dCA8PCAiPyAiIDw8IGkxIDw8ICcgJyA8PCBpMiA8PCAnICcgPDwgaTMgPDwgJyAnIDw8IGk0IDw8IGVuZGw7CglpbnQgVmE7IGNpbiA+PiBWYTsKCXJldHVybiBWYTsKfQppbmxpbmUgdm9pZCBzb2x2ZTIoaW50IHJvdywgaW50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