#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	long long num = 2, x, y;
	vector <int> a(100, 0), b(100, 0);
	cout << "? ";
	for (int i = 0; i < 100; ++i) {
		cout << num << " ";
		a[i] = num;
		num += 2;
	}
	cout << endl;
	cout.flush();
	cin >> x;
	num += 4;
	cout << "? ";
	for (int i = 0; i < 100; ++i) {
		cout << num << " ";
		b[i] = num;
		num += 3;
	}
	cout << endl;
	cout.flush();
	cin >> y;
	for (int i = 0; i < 100; ++i)
		for (int j = 0; j < 100; ++j)
			if ((a[i] ^ x) == (b[j] ^ y)) {
				cout << "! " << (a[i] ^ x) << endl;
				cout.flush();
				return 0;
			}
	return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int num = 1, x, y;
	vector <int> a(100, 0), b(100, 0);
	cout << "? ";
	for (int i = 0; i < 100; ++i) {
		cout << num << " ";
		a[i] = num;
		num += 2;
	}
	cout << endl;
	cout.flush();
	cin >> x;
	num = 0;
	cout << " ?";
	for (int i = 0; i < 100; ++i) {
		cout << num << " ";
		b[i] = num;
		num += 2;
	}
	cout << endl;
	cout.flush();
	cin >> y;
	for (int i = 99; i >= 0; --i)
		for (int j = 99; j >= 0; --j)
			if ((a[i] ^ b[j]) == (x ^ y)) {
				cout << "! " << (a[i] ^ x) << endl;
				cout.flush();
				return 0;
			}
	return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int num = 1, x, y;
	vector <int> a(100, 0), b(100, 0);
	cout << "? ";
	for (int i = 0; i < 100; ++i) {
		cout << num << " ";
		a[i] = num;
		num += 2;
	}
	cout << endl;
	cout.flush();
	cin >> x;
	num = 0;
	cout << " ?";
	for (int i = 0; i < 100; ++i) {
		cout << num << " ";
		b[i] = num;
		num += 2;
	}
	cout << endl;
	cout.flush();
	cin >> y;
	for (int i = 0; i < 100; ++i)
		for (int j = 0; j < 100; ++j)
			if (abs(a[i] - b[j]) == (x ^ y)) {
				cout << "! " << (a[i] ^ x);
				return 0;
			}
	return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int x, y, ans = 0;
	cout << "? ";
	for (int i = 1; i <= 100; ++i)
		cout << i << " ";
	cout << endl;
	cout.flush();
	cin >> x;
	cout << "? ";
	for (int i = 1; i <= 100; ++i)
		cout << (i << 7) << " ";
	cout << endl;
	cout.flush();
	cin >> y;
	ans |= (x & (((1 << 7) - 1) << 7));
	ans |= (y & ((1 << 7) - 1));
	cout << "! " << ans;
	cout.flush();
	return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int num = 2, x, y;
	vector <int> a(100, 0), b(100, 0);
	cout << "? ";
	for (int i = 0; i < 100; ++i) {
		cout << num << " ";
		a[i] = num;
		num += 2;
	}
	cout << endl;
	cout.flush();
	cin >> x;
	num += 4;
	cout << "? ";
	for (int i = 0; i < 100; ++i) {
		cout << num << " ";
		b[i] = num;
		num += 3;
	}
	cout << endl;
	cout.flush();
	cin >> y;
	for (int i = 0; i < 100; ++i)
		for (int j = 0; j < 100; ++j)
			if ((a[i] ^ x) == (b[j] ^ y)) {
				cout << "! " << (a[i] ^ x) << endl;
				cout.flush();
				return 0;
			}
	return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int x, y, ans = 0;
	cout << "? ";
	for (int i = 1; i <= 100; ++i)
		cout << i << " ";
	cout << endl;
	cout.flush();
	cin >> x;
	for (int i = 1; i <= 100; ++i)
		cout << (i << 7) << " ";
	cout << endl;
	cout.flush();
	cin >> y;
	ans |= (x & (((1 << 7) - 1) << 7));
	ans |= (y & ((1 << 7) - 1));
	cout << "! " << ans;
	cout.flush();
	return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int num = 1, x, y;
	vector <int> a(100, 0), b(100, 0);
	cout << "? ";
	for (int i = 0; i < 100; ++i) {
		cout << num << " ";
		a[i] = num;
		num += 2;
	}
	cout << endl;
	cout.flush();
	cin >> x;
	num = 0;
	cout << "? ";
	for (int i = 0; i < 100; ++i) {
		cout << num << " ";
		b[i] = num;
		num += 2;
	}
	cout << endl;
	cout.flush();
	cin >> y;
	for (int i = 0; i < 100; ++i)
		for (int j = 0; j < 100; ++j)
			if ((a[i] ^ b[j]) == (x ^ y)) {
				cout << "! " << (a[i] ^ x) << endl;
				cout.flush();
				return 0;
			}
	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

struct vertex {
	vector <int> edge;
	int cnt;
};

vector <vertex> graph;
vector <bool> used;
double l = 0, cnt = 0;

void dfs(int v, int c) {
	bool flag = 1;
	used[v] = 1;
	graph[v].cnt = c;
	for (int i = 0; i < graph[v].edge.size(); ++i)
		if (!used[graph[v].edge[i]]) {
			flag = 0;
			dfs(graph[v].edge[i], graph[v].cnt + 1);
		}
	if (flag) {
		++cnt;
		l += graph[v].cnt;
	}
}

int main() {
	int n;
	cin >> n;
	used.resize(n);
	graph.resize(n);
	for (int i = 0; i < n; ++i) {
		graph[i].cnt = 0;
		used[i] = 0;
	}
	for (int i = 0; i < n - 1; ++i) {
		int from, to;
		cin >> from >> to;
		graph[from - 1].edge.push_back(to - 1);
		graph[to - 1].edge.push_back(from - 1);
	}
	dfs(0, 0);
	cout << fixed << setprecision(8) << l / cnt;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    cout << "? ";
    for (int i=0; i<100; i++) {
        cout << (i<<7) << ' ';
    }
    cout << '\n';
    cout << flush;
    int x;
    cin >> x;
    x &= 127;

    cout << "? ";
    for (int i=1; i<=100; i++) {
        cout << i << ' ';
    }
    cout << '\n';
    cout << flush;
    int y;
    cin >> y;
    y &= (127<<7);

    cout << "! " << x+y << '\n';
    cout << flush;

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif

    cout << "? ";
    for (int i=0; i<100; i++) {
        cout << (i<<7) + 127 << ' ';
    }
    cout << '\n';
    cout << flush;
    int x;
    cin >> x;
    x &= 127;

    cout << "? ";
    for (int i=0; i<100; i++) {
        cout << (127<<7) + i << ' ';
    }
    cout << '\n';
    cout << flush;
    int y;
    cin >> y;
    y &= (127<<7);

    cout << "! " << x+y << '\n';
    cout << flush;

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL

    int lol = (1<<7) - 1;
    cout << "? ";
    for (int i=1; i<=100; i++) {
        cout << (i<<7) + lol << ' ';
    }
    fflush(stdout);
    int a;
    cin >> a;
    a %= (1<<7);
    int kek = (1<<14) - (1<<7);
    cout << "? ";
    for (int i=1; i<=100; i++) {
        cout << kek + i << ' ';
    }
    fflush(stdout);
    int b;
    cin >> b;
    b -= b%(1<<7);
    cout << a + b;

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif

    //00000001111111
    int a = (1<<7) - 1;
    //11111110000000
    int b = (1<<14) - (1<<7);
    int x,y;

    cout << "? ";
    for (int i=0; i<99; i++) {
        cout << (i<<7) + a << ' ';
    }
    cout << (99<<7) + a << '\n';
    cout << flush;

    cin >> x;
    if (x==-1) return 0;

    cout << "? ";
    for (int i=0; i<99; i++) {
        cout << b + i << ' ';
    }
    cout << b + 99 << '\n';
    cout << flush;

    cin >> y;
    if (y==-1) return 0;

    x %= (1<<7);
    y -= y%(1<<7);
    cout << "! " << x+y << '\n';
    cout << flush;

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif // LOCAL

    int lol = (1<<7) - 1;
    printf("? ");
    for (int i=0; i<100; i++) {
        cout << (i<<7) + lol << ' ';
    }
    cout << '\n';
    cout << fflush;
    int a;
    cin >> a;
    if (a==-1) return 0;
    a %= (1<<7);
    int kek = (1<<14) - (1<<7);
    cout << "? ";
    for (int i=0; i<100; i++) {
        cout << kek + i << ' ';
    }
    cout << '\n';
    cout << fflush;
    int b;
    cin >> b;
    if (b==-1) return 0;
    b -= b%(1<<7);
    cout << "! " << a+b << '\n';
    cout << fflush;

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL

    int lol = (1<<7) - 1;
    cout << "? ";
    for (int i=0; i<100; i++) {
        cout << (i<<7) + lol << ' ';
    }
    cout << '\n';
    fflush(stdout);
    int a;
    cin >> a;
    if (a==-1) return 0;
    a %= (1<<7);
    int kek = (1<<14) - (1<<7);
    cout << "? ";
    for (int i=0; i<100; i++) {
        cout << kek + i << ' ';
    }
    cout << '\n';
    fflush(stdout);
    int b;
    cin >> b;
    if (b==-1) return 0;
    b -= b%(1<<7);
    cout << "! " << a+b << '\n';
    fflush(stdout);

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    cout << "? ";
    for (int i=0; i<100; i++) {
        cout << (i<<7) << ' ';
    }
    cout << '\n';
    cout << flush;
    int x;
    cin >> x;
    x &= 127;

    cout << "? ";
    for (int i=0; i<100; i++) {
        cout << i << ' ';
    }
    cout << '\n';
    cout << flush;
    int y;
    cin >> y;
    y &= (127<<7);

    cout << "! " << x+y << '\n';
    cout << flush;

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif // LOCAL

    //00000001111111
    int a = (1<<7) - 1;
    //11111110000000
    int b = (1<<14) - (1<<7);
    int x,y;

    cout << "? ";
    for (int i=0; i<100; i++) {
        cout << (i<<7) + a << ' ';
    }
    cout << '\n';
    cout << fflush;
    cin >> x;

    cout << "? ";
    for (int i=0; i<100; i++) {
        cout << b + i << ' ';
    }
    cout << '\n';
    cout << fflush;
    cin >> y;

    x %= (1<<7);
    y -= y%(1<<7);
    cout << "! " << x+y << '\n';
    cout << fflush;

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif // LOCAL

    //00000001111111
    int a = (1<<7) - 1;
    //11111110000000
    int b = (1<<14) - (1<<7);
    int x,y;

    cout << "? ";
    for (int i=0; i<99; i++) {
        cout << (i<<7) + a << ' ';
    }
    cout << (99<<7) + a << '\n';
    cout << fflush;
    cin >> x;
    if (x==-1) return 0;

    cout << "? ";
    for (int i=0; i<99; i++) {
        cout << b + i << ' ';
    }
    cout << b + 99 << '\n';
    cout << fflush;
    cin >> y;
    if (y==-1) return 0;

    x %= (1<<7);
    y -= y%(1<<7);
    cout << "! " << x+y << '\n';
    cout << fflush;

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define LL long long

int a, b;

int main()
{
    cout << "? ";
    for (int i = 1; i <= 100; i++) {
        cout << i << " ";
    }

    cin >> a;
    a >>=7;
    a <<= 7;
    cout << "? ";
    for (int i =  1; i <= 100; i++) {
        cout << (1<<8) << " ";
    }

    cin >> b;
    b = b % 128;
    cout << "! ";
    cout << (a+b);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define LL long long

int main()
{
    cout << "? ";
    for (int i = 1; i <= 100; i++) {
        cout << 0 << " ";
    }
    int a;
    cin >> a;
    a >>=7;
    a <<= 7;
    cout << "? ";
    for (int i =  1; i <= 100; i++) {
        cout << (1<<8) << " ";
    }
    int b;
    cin >> b;
    b = b % 128;
    cout << "! ";
    cout << (int)(a+b);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define LL long long

int main()
{
    cout << "?";
    for (int i = 1; i <= 100; i++) {
        cout << " " << 0;
    }
    cout << endl;
    int t;
    cin >> t;
    int ans = 0;
    for (int i = 7; i < 14; i++) {
        ans += (t>>i&1)<<i;
    }
    cout << "?";
    for (int i = 1; i <= 100; i++) {
        cout << " " << (i<<8);
    }
    cout << endl;
    cin >> t;
    for (int i = 0; i < 7; i++) {
        ans += (t>>i&1) << i;
    }
    cout << "! " << ans << endl;
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define LL long long

int main()
{
    cout << "? ";
    for (int i = 1; i <= 100; i++) {
        cout << 0 << " ";
    }
    int a;
    cin >> a;
    a >>=7;
    a <<= 7;
    cout << "? ";
    for (int i =  1; i <= 100; i++) {
        cout << (1<<8) << " ";
    }
    int b;
    cin >> b;
    b = b % 128;
    cout << "! " << a+b;
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define LL long long

int main()
{
    cout << "? ";
    for (int i = 1; i <= 100; i++) {
        cout << 0 << " ";
    }
    int a;
    cin >> a;
    a >>=7;
    a <<= 7;
    cout << "? ";
    for (int i =  1; i <= 100; i++) {
        cout << (1<<8) << " ";
    }
    int b;
    cin >> b;
    b <<= 7;
    cout << "! " << a+b;
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define LL long long

int a, b;

int main()
{
    cout << "? ";
    for (int i = 1; i <= 100; i++) {
        cout << i << " ";
    }

    cin >> a;
    a >>=7;
    a <<= 7;
    cout << "? ";
    for (int i =  1; i <= 100; i++) {
        cout << (i<<7) << " ";
    }

    cin >> b;
    b = b % 128;
    cout << "! ";
    cout << (a+b);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
typedef long long ll;
const int inf=0x3f3f3f3f;
const int inn=0x80808080;
using namespace std;
int main(){
    printf("? ");
    for(int i=1;i<=100;i++){
        printf(" %d",i);
    }
    puts("");
    fflush(stdout);
    //
    int t;
    scanf("%d",&t);
    int ans=0;
    for(int i=7;i<14;i++){
        ans+=((t>>i&1)<<i);
    }
    //
    printf("? ");
    for(int i=1;i<=100;i++){
        printf(" %d",i<<7);
    }
    puts("");
    fflush(stdout);
    //
    scanf("%d",&t);
    for(int i=0;i<7;i++){
        ans+=((t>>i&1)<<i);
    }
    printf("! %d",ans);
    fflush(stdout);//这个地方可以不加了
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define LL long long

int a, b;

int main()
{
    cout << "? ";
    for (int i = 1; i <= 100; i++) {
        cout << i << " ";
    }

    cin >> a;
    a >>=7;
    a <<= 7;
    cout << "? ";
    for (int i =  1; i <= 100; i++) {
        cout << (i<<8) << " ";
    }

    cin >> b;
    b = b % 128;
    cout << "! ";
    cout << (a+b);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define LL long long

int main()
{
    cout << "? ";
    for (int i = 1; i <= 100; i++) {
        cout << 0 << " ";
    }
    int a;
    cin >> a;
    a >>=7;
    a <<= 7;
    cout << "? ";
    for (int i =  1; i <= 100; i++) {
        cout << (1<<8) << " ";
    }
    int b;
    cin >> b;
    b = b % 128;
    cout << "! ";
    cout << a+b;
    return 0;
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
int main()
{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	if (t == -1) return 0;
	cout << "?";
	for (int i = 101; i <= 200; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> g;
	if (g == -1) return 0;
	for (int i = 1; i <= 100; ++i)
	{
		mp[i^t]++;
	}
	for (int i = 101; i <= 200; ++i)
	{
		mp[i^g]++;
	}
	for (auto it : mp) if (it.second > 1) {
		cout << "! " << it.first << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
int main()
{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	//if (t == -1) return 0;
	cout << "?";
	for (int i = 101; i <= 200; ++i)
	{
		cout << " " << i<<8;
	}
	cout << endl;
	cin >> g;
	//if (g == -1) return 0;
	for (int i = 1; i <= 100; ++i)
	{
		mp[i^t]++;
	}
	for (int i = 101; i <= 200; ++i)
	{
		mp[(i<<8)^g]++;
	}
	for (auto it : mp) if (it.second > 1) {
		cout << "! " << it.first << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
int main()
{

	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	vi v1, v2;
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
	{
		v1.push_back(rnd());
		cout << " " << v1.back();
	}
	cout << endl;
	cin >> t;
	//if (t == -1) return 0;
	cout << "?";

	for (int i = 101; i <= 200; ++i)
	{
		v2.push_back(rnd());
		cout << " " << v2.back();
	}
	cout << endl;
	cin >> g;
	//if (g == -1) return 0;
	for(auto i : v1)
	{
		mp[i^t]++;
	}
	for(auto i : v2)
	{
		mp[i^g]++;
	}
	for (auto it : mp) if (it.second > 1) {
		cout << "! " << it.first << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
int main()
{

	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	//if (t == -1) return 0;
	cout << "?";
	for (int i = 101; i <= 200; ++i)
	{
		cout << " " << (i << 9);
	}
	cout << endl;
	cin >> g;
	//if (g == -1) return 0;
	for (int i = 1; i <= 100; ++i)
	{
		mp[i^t]++;
	}
	for (int i = 101; i <= 200; ++i)
	{
		mp[(i << 9) ^ g]++;
	}
	for (auto it : mp) if (it.second > 1) {
		cout << "! " << it.first << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;

bool ad[N];
vi v;
int main()
{

	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
		for (int j = 1; j <= 100; ++j)
			ad[i^j] = 1;
	for (int i = 101; i < (1 << 14); ++i)
	{
		bool flg = 1;
		for (auto it : v)
			if (ad[it^i])
			{
				flg = 0;
				break;
			}
		if (flg) v.push_back(i);
		if (v.size() == 100) break;
	}

	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	//if (t == -1) return 0;
	cout << "?";
	for (int i = 0; i < 100; ++i)
	{
		cout << " " << v[i];
	}
	cout << endl;
	cin >> g;
	fr(i, 100) fr(j, 100)
		if(((i+1)^t) == (v[j]^g))
	 {
		cout << "! " << (v[j] ^ g) << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
bool ad[N];
vi v;
int main()
{

	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
		for (int j = 1; j <= 100; ++j)
			ad[i^j] = 1;
	for (int i = 101; i < (1 << 14); ++i)
	{
		bool flg = 1;
		for (auto it : v)
			if (ad[it^i])
			{
				flg = 0;
				break;
			}
		if (flg) v.push_back(i);
		if (v.size() == 100) break;
	}

	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	//if (t == -1) return 0;
	cout << "?";
	for (int i = 0; i < 100; ++i)
	{
		cout << " " << v[i];
	}
	cout << endl;
	cin >> g;
	fr(i, 100) fr(j, 100) if((i+1)^t == v[j]^g)
	 {
		cout << "! " << (v[j] ^ g) << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
int main()
{

	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	//if (t == -1) return 0;
	cout << "?";
	for (int i = 101; i <= 200; ++i)
	{
		cout << " " << i<<8;
	}
	cout << endl;
	cin >> g;
	//if (g == -1) return 0;
	for (int i = 1; i <= 100; ++i)
	{
		mp[i^t]++;
	}
	for (int i = 101; i <= 200; ++i)
	{
		mp[(i<<8)^g]++;
	}
	for (auto it : mp) if (it.second > 1) {
		cout << "! " << it.first << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
int main()
{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	if (t == -1) return 0;
	cout << "?";
	for (int i = 101; i <= 200; ++i)
	{
		cout << " " << i<<8;
	}
	cout << endl;
	cin >> g;
	if (g == -1) return 0;
	for (int i = 1; i <= 100; ++i)
	{
		mp[i^t]++;
	}
	for (int i = 101; i <= 200; ++i)
	{
		mp[(i<<8)^g]++;
	}
	for (auto it : mp) if (it.second > 1) {
		cout << "! " << it.first << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
int main()
{

	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	//if (t == -1) return 0;
	cout << "?";
	for (int i = 101; i <= 200; ++i)
	{
		cout << " " << (i << 6);
	}
	cout << endl;
	cin >> g;
	//if (g == -1) return 0;
	for (int i = 1; i <= 100; ++i)
	{
		mp[i^t]++;
	}
	for (int i = 1; i <= 100; ++i)
	{
		mp[(i << 6) ^ g]++;
	}
	for (auto it : mp) if (it.second > 1) {
		cout << "! " << it.first << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
int main()
{

	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	//if (t == -1) return 0;
	cout << "?";
	for (int i = 101; i <= 200; ++i)
	{
		cout << " " << (i << 7);
	}
	cout << endl;
	cin >> g;
	//if (g == -1) return 0;
	for (int i = 1; i <= 100; ++i)
	{
		mp[i^t]++;
	}
	for (int i = 1; i <= 100; ++i)
	{
		mp[(i << 7) ^ g]++;
	}
	for (auto it : mp) if (it.second > 1) {
		cout << "! " << it.first << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
int main()
{

	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	//if (t == -1) return 0;
	cout << "?";
	for (int i = 101; i <= 200; ++i)
	{
		cout << " " << (i << 5);
	}
	cout << endl;
	cin >> g;
	//if (g == -1) return 0;
	for (int i = 1; i <= 100; ++i)
	{
		mp[i^t]++;
	}
	for (int i = 1; i <= 100; ++i)
	{
		mp[(i << 5) ^ g]++;
	}
	for (auto it : mp) if (it.second > 1) {
		cout << "! " << it.first << endl;
		return 0;
	}
}


/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300002;
map<int, int> mp;
bool ad[N];
vi v;
int main()
{

	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int t, g;
	cout << "?";
	for (int i = 1; i <= 100; ++i)
		for (int j = 1; j <= 100; ++j)
			ad[i^j] = 1;
	for (int i = 101; i < (1 << 14); ++i)
	{
		bool flg = 1;
		for (auto it : v)
			if (ad[it^i])
			{
				flg = 0;
				break;
			}
		if (flg) v.push_back(i);
		if (v.size() == 100) break;
	}

	for (int i = 1; i <= 100; ++i)
	{
		cout << " " << i;
	}
	cout << endl;
	cin >> t;
	//if (t == -1) return 0;
	cout << "?";
	for (int i = 0; i < 100; ++i)
	{
		cout << " " << v[i];
	}
	cout << endl;
	cin >> g;
	fr(i, 100) fr(j, 100) if((i+1)^t == v[j]^g)
	 {
		cout << "! " <<v[j] ^ g << endl;
		return 0;
	}
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    //cout << "Hello World!" << endl;
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    long long a[100],b[100],i,j;

    long long var=1;

    for(i=0;i<100;i++)
    {
        a[i]=i+1;
        b[i]=pow(2,14)-(i+1);
    }

    // for(i=100;i<200;i++)
    //     b[i-100]=(i+1);

    //cout<<b[0]<<endl;
    cout<<"? ";

    for(i=0;i<100;i++)
        cout<<a[i]<<" ";

    cout<<endl;

    long long x,y;

    cin>>x;
    cout<<x<<endl;
    fflush(stdout);

    for(i=0;i<100;i++)
        a[i]=a[i]^x;

    cout<<"? ";

    for(i=0;i<100;i++)
        cout<<b[i]<<" ";
    cout<<endl;

    cin>>y;
    cout<<y<<endl;
    fflush(stdout);

    for(i=0;i<100;i++)
        b[i]=b[i]^y;

    for(i=0;i<100;i++)
    {
        for(j=0;j<100;j++)
        {
            if(a[i]^b[i]==0)
            {
                cout<<"! "<<(a[i]^(i+1))<<endl;
                exit(0);
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    //cout << "Hello World!" << endl;
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    long long a[100],b[100],i,j;

    long long var=1;

    for(i=0;i<100;i++)
    {
        a[i]=i+1;
        b[i]=pow(2,14)-(i+1);
    }

    // for(i=100;i<200;i++)
    //     b[i-100]=(i+1);

    //cout<<b[0]<<endl;
    cout<<"? ";

    for(i=0;i<100;i++)
        cout<<a[i]<<" ";

    cout<<endl;

    long long x,y;

    cin>>x;
    cout<<x<<endl;
    fflush(stdout);

    for(i=0;i<100;i++)
        a[i]=a[i]^x;

    cout<<"? ";

    for(i=0;i<100;i++)
        cout<<b[i]<<" ";
    cout<<endl;

    cin>>y;
    cout<<y<<endl;
    fflush(stdout);

    for(i=0;i<100;i++)
        b[i]=b[i]^y;

    for(i=0;i<100;i++)
    {
        for(j=0;j<100;j++)
        {
            if(a[i]^b[i]==0)
            {
                cout<<"! "<<(x^(i+1))<<endl;
                exit(0);
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define ll long long
#define lmin LONG_MIN
#define lmax LONG_MAX
#define imin ll_MIN
#define imax ll_MAX
#define ffor(i,a,b) for(ll i=a;i<b;i++)
#define bfor(i,a,b) for(ll i=a-1;i>=b;i--)
#define mset(f,a) memset(f,a,sizeof(f))
#define pb push_back
#define MAXN   100001
ll M=1e9+7;

ll power(ll x ,ll y)
{
    if(y==0)
        return 1;

    ll t=power(x, y/2);

    t=((t%M)*(t%M))%M;

    if(y%2==1)
        t=((t%M)*(x%M))%M;

    return t;

}

ll spf[MAXN];

ll max(ll a, ll b)
{
    if(a>b)
        return a;

    return b;
}

ll min(ll a, ll b)
{
    if(a>b)
        return b;

    return a;
}

ll bfs(vector<ll>v[],ll n)
{
    ll i;
    n=100;
    ll dis[100+1]={0};
    ll flg[100+1]={0};

    priority_queue<ll>q;
    q.push(1);
    dis[1]=0;
    while(!q.empty())
    {
        ll u=q.top();
        q.pop();
        flg[u]=1;
        for(i=0;i<v[u].size();i++)
        {
            ll ve=v[u][i];

            if(flg[ve]==0)
            {
                q.push(ve);
                dis[ve]=dis[u]+1;
            }
        }
    }

    return dis[n];
}

bool sortinrev(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
       return (a.first > b.first);
}

ll isPrime(ll x)
{
    vector<ll>v;
    ll i;

    for(i=1;i*i<=x;i++)
    {
        if(x%i==0)
        {
            if(i*i==x)
                v.push_back(i);
            else
            {
                v.push_back(i);
                v.push_back(x/i);
            }
        }
    }

    return v.size()==2;
}

ll binary(vector<ll>a, ll x, ll l1,ll l2)
{
   // ll i;

    ll l=l1;
    ll r=l2;
    //cout<<x<<endl;
    while(r-l>1)
    {
        ll mid=(l+r)/2;

        if(a[mid]<x)
            l=mid;
        else
            r=mid;
    }
    //cout<<l<<" "<<r<<endl;
    if(a[l]<=x && a[r]>=x)
        return l;
    else if(a[r]>=x)
        return r;
    else
        return l;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

ll phi(ll n)
{
    ll result = n;

    for (ll p = 2; p * p <= n; ++p)
    {
        if (n % p == 0) {
            while (n % p == 0)
                n /= p;
            result -= result / p;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
void dfs(ll source,ll visited[],vector<ll>graph[],ll l)
{
    visited[source]=l;
    ll i;

    for(i=0;i<graph[source].size();i++)
    {
        if(visited[graph[source][i]]==-1)
            dfs(graph[source][i], visited, graph, l);
    }
}
ll day(ll d, ll m, ll y)
{
	static ll t[] = { 0, 3, 2, 5, 0, 3,
					5, 1, 4, 6, 2, 4 };
	y -= m < 3;
	return ( y + y / 4 - y / 100 +
			y / 400 + t[m - 1] + d) % 7;
}

bool isPerfectSquare(long double x)
{

  long double sr = sqrt(x);

  return ((sr - floor(sr)) == 0);
}

ll getMid(ll s, ll e) { return s + (e -s)/2; }

ll getSumUtil(ll *st, ll ss, ll se, ll qs, ll qe, ll si)
{

    if (qs <= ss && qe >= se)
        return st[si];

    if (se < qs || ss > qe)
        return 0;

    ll mid = getMid(ss, se);
    return getSumUtil(st, ss, mid, qs, qe, 2*si+1) +
        getSumUtil(st, mid+1, se, qs, qe, 2*si+2);
}

void updateValueUtil(ll *st, ll ss, ll se, ll i, ll diff, ll si)
{

    if (i < ss || i > se)
        return;

    st[si] = st[si] + diff;
    if (se != ss)
    {
        ll mid = getMid(ss, se);
        updateValueUtil(st, ss, mid, i, diff, 2*si + 1);
        updateValueUtil(st, mid+1, se, i, diff, 2*si + 2);
    }
}

void updateValue(ll arr[], ll *st, ll n, ll i, ll new_val)
{

    ll diff = new_val - arr[i];

    arr[i] = new_val;

    updateValueUtil(st, 0, n-1, i, diff, 0);
}

ll getSum(ll *st, ll n, ll qs, ll qe)
{

    return getSumUtil(st, 0, n-1, qs, qe, 0);
}

ll constructSTUtil(ll arr[], ll ss, ll se, ll *st, ll si)
{

    if (ss == se)
    {
        ll c=0,x=arr[ss];

        while(x>0)
        {
            if(x%2==1)
                c++;
            x/=2;
        }

        if(c%2==0)
            st[si] = 1;
        else
            st[si] = 0;
        return st[si];
    }

    ll mid = getMid(ss, se);
    st[si] = constructSTUtil(arr, ss, mid, st, si*2+1) +
            constructSTUtil(arr, mid+1, se, st, si*2+2);
    return st[si];
}

ll *constructST(ll arr[], ll n)
{

    ll x = (ll)(ceil(log2(n)));

    ll max_size = 2*(ll)pow(2, x) - 1;

    ll *st = new ll[max_size];

    constructSTUtil(arr, 0, n-1, st, 0);

    return st;
}
void output()
{
    ll i,x,y;

    cout<<"? ";
    for(i=128;i<=12800;i+=128)
        cout<<i-1<<" ";
    cout<<endl;

    cin>>x;

    cout<<"? ";

    for(i=power(2,14)-1-127;i<power(2,14)-1-27;i++)
        cout<<i<<" ";
    cout<<endl;

    cin>>y;

    ll a[20]={0};

    ll v;

    v=127;
    ll l=0;
    while(l<7)
    {
        if(x%2==1)
            a[l]=0;
        else
        {
            a[l]=1;
        }

        l++;
        v=v/2;
        x=x/2;
    }

    l=7;
    v=power(2,14)-1-127;

    for(i=0;i<7;i++)
        y=y/2;

    while(l<14)
    {
        if(y%2==1)
            a[l]=0;
        else
        {
            a[l]=1;
        }
        y=y/2;
        l++;

    }

    x=0;

    for(i=15;i>=0;i--)
    {
        //cout<<x<<endl;
        x=x+power(2,i)*a[i];
        //cout<<x<<endl;
    }

    cout<<"! "<<x<<endl;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    //cout<<"10\n";

    int t;
    t=1;
    //cin>>t;
    //ll c=0;

    while(t--)
    {

        output();

    }
    //cout<<c<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    //cout << "Hello World!" << endl;

    long long i,j,m=pow(2,14);

    cout<<"? ";

    for(i=1;i<=100;i++)
        cout<<i<<" ";
    cout<<endl;

    long long x;
    cin>>x;

    vector<long long>v;

    for(i=1;i<=100;i++)
    {
        for(j=0;j<m;j++)
        {
            //cout<<j<<endl;
            if((i^j)==x)
                v.push_back(j);
        }
    }

    cout<<"? ";

    for(i=101;i<=200;i++)
        cout<<i<<" ";
    cout<<endl;

    cin>>x;

    for(i=101;i<=200;i++)
    {
        for(j=0;j<v.size();j++)
        {
            if((i^v[j])==x)
            {
                //cout<<i<<endl;
                //cout<<(i^v[j])<<endl;
                cout<<"! ";
                cout<<v[j]<<endl;

                exit(0);
            }
        }
    }
    return 0;
}


//
//  main.cpp
//  Code1
//
//  Created by Aaditya Gadhave on 01/08/19.
//  Copyright © 2019 Aaditya Gadhave. All rights reserved.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <map>
#include<set>
#include<vector>
using namespace std;
long long m=1e9+7;

int main(int argc, const char * argv[]) {
    // insert code here...1

    //cout << "Hello World!" << endl;
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    long long a[100],b[100],i,j;

    long long var=1;

    for(i=1;i<=14;i++)
        var=var*2;

    for(i=0;i<100;i++)
    {
        a[i]=i+1;
        b[i]=var-(i+1);
    }

    //cout<<b[0]<<endl;
    cout<<"? ";

    for(i=0;i<100;i++)
        cout<<a[i]<<" ";
    cout<<endl;

    long long x,y;

    cin>>x;

    for(i=0;i<100;i++)
        a[i]=a[i]^x;

    cout<<"? ";

    for(i=0;i<100;i++)
        cout<<b[i]<<" ";
    cout<<endl;
    cin>>y;

    for(i=0;i<100;i++)
        b[i]=b[i]^y;

    for(i=0;i<100;i++)
    {
        for(j=0;j<100;j++)
        {
            if(a[i]==b[j])
            {
                cout<<"! "<<a[i]<<endl;
                exit(0);
            }
        }
    }
    return 0;

}


#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define ll long long
#define lmin LONG_MIN
#define lmax LONG_MAX
#define imin ll_MIN
#define imax ll_MAX
#define ffor(i,a,b) for(ll i=a;i<b;i++)
#define bfor(i,a,b) for(ll i=a-1;i>=b;i--)
#define mset(f,a) memset(f,a,sizeof(f))
#define pb push_back
#define MAXN   100001
ll M=1e9+7;

ll power(ll x ,ll y)
{
    if(y==0)
        return 1;

    ll t=power(x, y/2);

    t=((t%M)*(t%M))%M;

    if(y%2==1)
        t=((t%M)*(x%M))%M;

    return t;

}

ll spf[MAXN];

ll max(ll a, ll b)
{
    if(a>b)
        return a;

    return b;
}

ll min(ll a, ll b)
{
    if(a>b)
        return b;

    return a;
}

ll bfs(vector<ll>v[],ll n)
{
    ll i;
    n=100;
    ll dis[100+1]={0};
    ll flg[100+1]={0};

    priority_queue<ll>q;
    q.push(1);
    dis[1]=0;
    while(!q.empty())
    {
        ll u=q.top();
        q.pop();
        flg[u]=1;
        for(i=0;i<v[u].size();i++)
        {
            ll ve=v[u][i];

            if(flg[ve]==0)
            {
                q.push(ve);
                dis[ve]=dis[u]+1;
            }
        }
    }

    return dis[n];
}

bool sortinrev(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
       return (a.first > b.first);
}

ll isPrime(ll x)
{
    vector<ll>v;
    ll i;

    for(i=1;i*i<=x;i++)
    {
        if(x%i==0)
        {
            if(i*i==x)
                v.push_back(i);
            else
            {
                v.push_back(i);
                v.push_back(x/i);
            }
        }
    }

    return v.size()==2;
}

ll binary(vector<ll>a, ll x, ll l1,ll l2)
{
   // ll i;

    ll l=l1;
    ll r=l2;
    //cout<<x<<endl;
    while(r-l>1)
    {
        ll mid=(l+r)/2;

        if(a[mid]<x)
            l=mid;
        else
            r=mid;
    }
    //cout<<l<<" "<<r<<endl;
    if(a[l]<=x && a[r]>=x)
        return l;
    else if(a[r]>=x)
        return r;
    else
        return l;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

ll phi(ll n)
{
    ll result = n;

    for (ll p = 2; p * p <= n; ++p)
    {
        if (n % p == 0) {
            while (n % p == 0)
                n /= p;
            result -= result / p;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
void dfs(ll source,ll visited[],vector<ll>graph[],ll l)
{
    visited[source]=l;
    ll i;

    for(i=0;i<graph[source].size();i++)
    {
        if(visited[graph[source][i]]==-1)
            dfs(graph[source][i], visited, graph, l);
    }
}
ll day(ll d, ll m, ll y)
{
	static ll t[] = { 0, 3, 2, 5, 0, 3,
					5, 1, 4, 6, 2, 4 };
	y -= m < 3;
	return ( y + y / 4 - y / 100 +
			y / 400 + t[m - 1] + d) % 7;
}

bool isPerfectSquare(long double x)
{

  long double sr = sqrt(x);

  return ((sr - floor(sr)) == 0);
}

ll getMid(ll s, ll e) { return s + (e -s)/2; }

ll getSumUtil(ll *st, ll ss, ll se, ll qs, ll qe, ll si)
{

    if (qs <= ss && qe >= se)
        return st[si];

    if (se < qs || ss > qe)
        return 0;

    ll mid = getMid(ss, se);
    return getSumUtil(st, ss, mid, qs, qe, 2*si+1) +
        getSumUtil(st, mid+1, se, qs, qe, 2*si+2);
}

void updateValueUtil(ll *st, ll ss, ll se, ll i, ll diff, ll si)
{

    if (i < ss || i > se)
        return;

    st[si] = st[si] + diff;
    if (se != ss)
    {
        ll mid = getMid(ss, se);
        updateValueUtil(st, ss, mid, i, diff, 2*si + 1);
        updateValueUtil(st, mid+1, se, i, diff, 2*si + 2);
    }
}

void updateValue(ll arr[], ll *st, ll n, ll i, ll new_val)
{

    ll diff = new_val - arr[i];

    arr[i] = new_val;

    updateValueUtil(st, 0, n-1, i, diff, 0);
}

ll getSum(ll *st, ll n, ll qs, ll qe)
{

    return getSumUtil(st, 0, n-1, qs, qe, 0);
}

ll constructSTUtil(ll arr[], ll ss, ll se, ll *st, ll si)
{

    if (ss == se)
    {
        ll c=0,x=arr[ss];

        while(x>0)
        {
            if(x%2==1)
                c++;
            x/=2;
        }

        if(c%2==0)
            st[si] = 1;
        else
            st[si] = 0;
        return st[si];
    }

    ll mid = getMid(ss, se);
    st[si] = constructSTUtil(arr, ss, mid, st, si*2+1) +
            constructSTUtil(arr, mid+1, se, st, si*2+2);
    return st[si];
}

ll *constructST(ll arr[], ll n)
{

    ll x = (ll)(ceil(log2(n)));

    ll max_size = 2*(ll)pow(2, x) - 1;

    ll *st = new ll[max_size];

    constructSTUtil(arr, 0, n-1, st, 0);

    return st;
}
void output()
{
    ll i,x,y;

    cout<<"? ";
    for(i=128;i<=12800;i+=128)
        cout<<i-1<<" ";
    cout<<endl;

    cin>>x;

    cout<<"? ";

    for(i=power(2,14)-1-127;i<power(2,14)-1-27;i++)
        cout<<i<<" ";
    cout<<endl;

    cin>>y;

    ll a[20]={0};

    ll v;

    v=127;
    ll l=0;
    while(v>0 && x>0)
    {
        if(x%2==1)
            a[l]=0;
        else
        {
            a[l]=1;
        }

        l++;
        v=v/2;
        x=x/2;
    }

    l=7;
    v=power(2,14)-1-127;

    for(i=0;i<7;i++)
        y=y/2;

    while(y>0)
    {
        if(y%2==1)
            a[l]=0;
        else
        {
            a[l]=1;
        }
        y=y/2;
        l++;

    }

    x=0;

    for(i=15;i>=0;i--)
    {
        //cout<<x<<endl;
        x=x+power(2,i)*a[i];
        //cout<<x<<endl;
    }

    cout<<"! "<<x<<endl;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    //cout<<"10\n";

    int t;
    t=1;
    //cin>>t;
    //ll c=0;

    while(t--)
    {

        output();

    }
    //cout<<c<<endl;
    return 0;
}


#define TC_GEN 1
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<set>
#include<random>
#include<stack>
using namespace std;
using lld = long long int;
using llu = unsigned long long int;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using pll = pair<lld, lld>;
using piii = pair<pii, pii>;
using pdii = pair<int, pii>;
set<piii> ss;
char xx[100009];
piii build(pii p, pii q) {
	if (p < q)return piii(p, q);
	return piii(q, p);
}
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	scanf("%d", &t);
	while (t--) {
		ss.clear();
		scanf("%s", xx);
		pii cur = pii(0, 0);
		int res = 0;
		for (i = 0; xx[i]; i++) {
			pii nxt = cur;
			if (xx[i] == 'N')nxt.first -= 1;
			if (xx[i] == 'S')nxt.first += 1;
			if (xx[i] == 'E')nxt.second += 1;
			if (xx[i] == 'W')nxt.second -= 1;
			piii bb = build(cur, nxt);
			if (ss.find(bb) == ss.end()) {
				res += 5;
				ss.insert(bb);
			}
			else { res++; }
			cur = nxt;
		}
		printf("%d\n", res);
	}
}


#pragma once
#include <iostream>
#include<list>
#include<vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

void testcase() {
	long long result = 0;
	pair<long long, long long> curr = make_pair(0, 0);
	set<pair<long long, long long>> s;
	s.insert(curr);
	std::string name;
	getline(std::cin, name);

	for (int i = 0; i < name.length(); i++) {
		char c = name[i];
		if (c == 'N') {
			curr.second++;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else if (c == 'S') {
			curr.second--;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else if (c == 'W') {
			curr.first++;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else { // East here
			curr.first--;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
	}

	std::cout << result << "\n";

}

int main() {
	int s; std::cin >> s;
	for (int i = 0; i < s; i++) {
		testcase();
	}

	return 0;
}


#pragma once
#include <iostream>
#include<list>
#include<vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

void testcase() {
	long long result = 0;
	pair<long long, long long> curr = make_pair(0, 0);
	set<pair<long long, long long>> s;
	s.insert(curr);
	string name;
	getline(cin, name);

	for (int i = 0; i < name.length(); i++) {
		char c = name[i];
		if (c == 'N') {
			curr.second++;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else if (c == 'S') {
			curr.second--;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else if (c == 'W') {
			curr.first++;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else { // East here
			curr.first--;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
	}

	std::cout << result << "\n";

}

int main() {
	int s; std::cin >> s;
	string name;
	getline(cin, name);
	for (int i = 0; i < s; i++) {
		testcase();
	}

	return 0;
}


#pragma once
#include <iostream>
#include<list>
#include<vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

void testcase() {
	long long result = 0;
	pair<double, double> curr = make_pair(0, 0);
	set<pair<double, double>> s;
	//s.insert(curr);
	string name;
	getline(cin, name);

	for (int i = 0; i < name.length(); i++) {
		char c = name[i];
		if (c == 'N') {
			curr.second += 0.5;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);

			}
			curr.second += 0.5;
		}
		else if (c == 'S') {
			curr.second -= 0.5;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
			curr.second -= 0.5;
		}
		else if (c == 'W') {
			curr.first += 0.5;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
			curr.first += 0.5;
		}
		else if(c == 'E') { // East here
			curr.first -= 0.5;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
			curr.first -= 0.5;
		}
	}

	std::cout << result << "\n";

}

int main() {
	int s; std::cin >> s;
	string name;
	getline(cin, name);
	for (int i = 0; i < s; i++) {
		testcase();
	}

	return 0;
}


#pragma once
#include <iostream>
#include<list>
#include<vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

void testcase() {
	long long result = 0;
	pair<long long, long long> curr = make_pair(0, 0);
	set<pair<long long, long long>> s;
	//s.insert(curr);
	string name;
	getline(cin, name);

	for (int i = 0; i < name.length(); i++) {
		char c = name[i];
		if (c == 'N') {
			curr.second++;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else if (c == 'S') {
			curr.second--;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else if (c == 'W') {
			curr.first++;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else if(c == 'E') { // East here
			curr.first--;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
	}

	std::cout << result << "\n";

}

int main() {
	int s; std::cin >> s;
	string name;
	getline(cin, name);
	for (int i = 0; i < s; i++) {
		testcase();
	}

	return 0;
}


#pragma once
#include <iostream>
#include<list>
#include<vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

void testcase() {
	long long result = 0;
	pair<long long, long long> curr = make_pair(0, 0);
	set<pair<long long, long long>> s;
	//s.insert(curr);
	string name;
	getline(cin, name);

	for (int i = 0; i < name.length(); i++) {
		char c = name[i];
		if (c == 'N') {
			curr.second++;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
				curr.second++;
			}
		}
		else if (c == 'S') {
			curr.second--;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
				curr.second--;
			}
		}
		else if (c == 'W') {
			curr.first++;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
				curr.first++;
			}
		}
		else if(c == 'E') { // East here
			curr.first--;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
				curr.first--;
			}
		}
	}

	std::cout << result << "\n";

}

int main() {
	int s; std::cin >> s;
	string name;
	getline(cin, name);
	for (int i = 0; i < s; i++) {
		testcase();
	}

	return 0;
}


#pragma once
#include <iostream>
#include<list>
#include<vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

void testcase() {
	long long result = 0;
	pair<long long, long long> curr = make_pair(0, 0);
	set<pair<long long, long long>> s;
	s.insert(curr);
	string name;
	getline(cin, name);

	for (int i = 0; i < name.length(); i++) {
		char c = name[i];
		if (c == 'N') {
			curr.second++;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);

			}
		}
		else if (c == 'S') {
			curr.second--;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else if (c == 'W') {
			curr.first++;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
		else if(c == 'E') { // East here
			curr.first--;
			if (s.find(curr) != s.end()) {
				result += 1;
			}
			else {
				result += 5;
				s.insert(curr);
			}
		}
	}

	std::cout << result << "\n";

}

int main() {
	int s; std::cin >> s;
	string name;
	getline(cin, name);
	for (int i = 0; i < s; i++) {
		testcase();
	}

	return 0;
}


#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}
ll Power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2，判断b的奇偶性
			ans = ans * a % p; //如果为奇数，证明该位为1，需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
bool isprime(ll num)
{
	if (num == 2 || num == 3)
		return true;
	if (num % 6 != 1 && num % 6 != 5)
		return false;
	ll t = sqrt((double)num);
	for (ll i = 5; i <= t; i += 6)
		if (num % i == 0 || num % (i + 2) == 0)
			return false;
	return true;
}
bool isRunyear(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return true;
	}
	else {
		return false;
	}
}
ll n, m, i, j, k, t;
const ll INF = 1e5+10;
string s;
int main() {
	FAST_IO;
	while (cin >> k) {
		while (k--) {
			cin >> s;
			set<pair<ll, ll>>sv;
			pair<ll, ll>p;
			p.first = p.second = INF;
			ll sum = 0;
			for (i = 0, j = s.length(); i < j; i++) {
				sv.insert(p);
				if (s[i] == 'S')p.first--;
				if (s[i] == 'N')p.first++;
				if (s[i] == 'W')p.second--;
				if (s[i] == 'E')p.second++;
				if (sv.count(p))sum++;
				else sum += 5;
				sv.insert(p);
			}
			cout << sum << endl;
		}
	}
}


#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}
ll Power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2，判断b的奇偶性
			ans = ans * a % p; //如果为奇数，证明该位为1，需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
bool isprime(ll num)
{
	if (num == 2 || num == 3)
		return true;
	if (num % 6 != 1 && num % 6 != 5)
		return false;
	ll t = sqrt((double)num);
	for (ll i = 5; i <= t; i += 6)
		if (num % i == 0 || num % (i + 2) == 0)
			return false;
	return true;
}
bool isRunyear(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return true;
	}
	else {
		return false;
	}
}
ll n, m, i, j, k, t;
const ll INF = 1e5+10;
string s;
int main() {
	FAST_IO;
	while (cin >> k) {
		while (k--) {
			cin >> s;
			map<ll, map<ll, ll>>mm;
			ll x = INF, y = INF;
			mm[x][y]++;
			ll sum = 0;
			for (i = 0, j = s.length(); i < j; i++) {
				if (s[i] == 'S')x--;
				if (s[i] == 'N')x++;
				if (s[i] == 'W')y--;
				if (s[i] == 'E')y++;
				if (mm[x][y])sum++;
				else sum += 5;
				mm[x][y]++;
			}
			cout << sum << endl;
		}
	}
}


#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}
ll Power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2，判断b的奇偶性
			ans = ans * a % p; //如果为奇数，证明该位为1，需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
bool isprime(ll num)
{
	if (num == 2 || num == 3)
		return true;
	if (num % 6 != 1 && num % 6 != 5)
		return false;
	ll t = sqrt((double)num);
	for (ll i = 5; i <= t; i += 6)
		if (num % i == 0 || num % (i + 2) == 0)
			return false;
	return true;
}
bool isRunyear(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return true;
	}
	else {
		return false;
	}
}
ll n, m, i, j, k, t;
const ll INF = 1e5+10;
string s;
int main() {
	FAST_IO;
	while (cin >> k) {
		getchar();
		while (k--) {
			getline(cin, s);
			set<pair<ll, ll>>sv;
			pair<ll, ll>p;
			p.first = p.second = 0;
			ll sum = 0;
			for (i = 0, j = s.length(); i < j; i++) {
				sv.insert(p);
				if (s[i] == 'S')p.first--;
				if (s[i] == 'N')p.first++;
				if (s[i] == 'W')p.second--;
				if (s[i] == 'E')p.second++;
				if (sv.count(p))sum++;
				else sum += 5;
				sv.insert(p);
			}
			cout << sum << endl;
		}
	}
}


#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}
ll Power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2，判断b的奇偶性
			ans = ans * a % p; //如果为奇数，证明该位为1，需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
bool isprime(ll num)
{
	if (num == 2 || num == 3)
		return true;
	if (num % 6 != 1 && num % 6 != 5)
		return false;
	ll t = sqrt((double)num);
	for (ll i = 5; i <= t; i += 6)
		if (num % i == 0 || num % (i + 2) == 0)
			return false;
	return true;
}
bool isRunyear(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return true;
	}
	else {
		return false;
	}
}
ll n, m, i, j, k, t;
const ll INF = 1e5+10;
string s;
int main() {
	FAST_IO;
	while (cin >> k) {
		while (k--) {
			cin >> s;
			set<pair<ll, ll>>sv;
			pair<ll, ll>p;
			p.first = p.second = 0;
			ll sum = 0;
			for (i = 0, j = s.length(); i < j; i++) {
				sv.insert(p);
				if (s[i] == 'S')p.first--;
				if (s[i] == 'N')p.first++;
				if (s[i] == 'W')p.second--;
				if (s[i] == 'E')p.second++;
				if (sv.count(p))sum++;
				else sum += 5;
				sv.insert(p);
			}
			cout << sum << endl;
		}
	}
}


#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}
ll Power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2，判断b的奇偶性
			ans = ans * a % p; //如果为奇数，证明该位为1，需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
bool isprime(ll num)
{
	if (num == 2 || num == 3)
		return true;
	if (num % 6 != 1 && num % 6 != 5)
		return false;
	ll t = sqrt((double)num);
	for (ll i = 5; i <= t; i += 6)
		if (num % i == 0 || num % (i + 2) == 0)
			return false;
	return true;
}
bool isRunyear(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return true;
	}
	else {
		return false;
	}
}
ll n, m, i, j, k, t;
const ll INF = 1e5+10;
string s;
int main() {
	FAST_IO;
	while (cin >> k) {
		while (k--) {
			cin >> s;
			map<pair<ll, ll>,ll>mm;
			pair<ll, ll>p;
			p.first = p.second = 0;
			ll sum = 0;
			for (i = 0, j = s.length(); i < j; i++) {
				mm[p] = 1;
				if (s[i] == 'S')p.first--;
				if (s[i] == 'N')p.first++;
				if (s[i] == 'W')p.second--;
				if (s[i] == 'E')p.second++;
				if (mm[p])sum++;
				else sum += 5;
			}
			cout << sum << endl;
		}
	}
}


#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}
ll Power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2，判断b的奇偶性
			ans = ans * a % p; //如果为奇数，证明该位为1，需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
bool isprime(ll num)
{
	if (num == 2 || num == 3)
		return true;
	if (num % 6 != 1 && num % 6 != 5)
		return false;
	ll t = sqrt((double)num);
	for (ll i = 5; i <= t; i += 6)
		if (num % i == 0 || num % (i + 2) == 0)
			return false;
	return true;
}
bool isRunyear(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return true;
	}
	else {
		return false;
	}
}
ll n, m, i, j, k, t;
const ll INF = 1e5+10;
string s;
int main() {
	FAST_IO;
	while (cin >> k) {
		while (k--) {
			cin >> s;
			map<pair<ll, ll>,ll>mm;
			mm.clear();
			pair<ll, ll>p;
			p.first = p.second = 0;
			ll sum = 0;
			for (i = 0, j = s.length(); i < j; i++) {
				if (s[i] == 'S') {//上
					ll a = mm[p] & 2;
					if (a == 2) {
						sum++;
						p.first--;
					}
					else {
						sum += 5;
						mm[p] += 2;
						p.first--;
						mm[p] += 4;
					}
				}
				if (s[i] == 'N') {//下
					ll a = mm[p] & 4;
					if (a == 4) {
						sum++;
						p.first++;
					}
					else {
						sum += 5;
						mm[p] += 4;
						p.first++;
						mm[p] += 2;
					}
				}
				if (s[i] == 'W') {//左
					ll a = mm[p] & 8;
					if (a == 8) {
						sum++;
						p.second--;
					}
					else {
						sum += 5;
						mm[p] += 8;
						p.second--;
						mm[p] += 16;
					}
				}
				if (s[i] == 'E') {//右
					ll a = mm[p] & 16;
					if (a == 16) {
						sum++;
						p.second++;
					}
					else {
						sum += 5;
						mm[p] += 16;
						p.second++;
						mm[p] += 8;
					}
				}
			}
			cout << sum << endl;
		}
	}
}


#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef pair<ll, ll> inin;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}
ll Power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2，判断b的奇偶性
			ans = ans * a % p; //如果为奇数，证明该位为1，需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
bool isprime(ll num)
{
	if (num == 2 || num == 3)
		return true;
	if (num % 6 != 1 && num % 6 != 5)
		return false;
	ll t = sqrt((double)num);
	for (ll i = 5; i <= t; i += 6)
		if (num % i == 0 || num % (i + 2) == 0)
			return false;
	return true;
}
bool isRunyear(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return true;
	}
	else {
		return false;
	}
}
string add(string s1, string s2)
{
	if (s1.length() < s2.length())
	{
		string temp = s1;
		s1 = s2;
		s2 = temp;
	}
	int i, j;
	for (i = s1.length() - 1, j = s2.length() - 1; i >= 0; i--, j--)
	{
		s1[i] = char(s1[i] + (j >= 0 ? s2[j] - '0' : 0));   //注意细节
		if (s1[i] - '0' >= 10)
		{
			s1[i] = char((s1[i] - '0') % 10 + '0');
			if (i) s1[i - 1]++;
			else s1 = '1' + s1;
		}
	}
	return s1;
}
ll n, m, i, j, k, t;
const ll INF = 1e5+10;
string s;
int main() {
	FAST_IO;
	while (cin >> k) {
		while (k--) {
			cin >> s;
			set<pair<inin, inin>>st;
			ll sum = 0, x = 0, y = 0;
			for (i = 0, j = s.length(); i < j; i++) {
				inin p = { x,y };
				if (s[i] == 'S')x--;
				if (s[i] == 'N')x++;
				if (s[i] == 'W')y--;
				if (s[i] == 'E')y++;
				if (st.count({ p,{x,y} }))sum++;
				else sum += 5;
				st.insert({ p,{x,y} });
				st.insert({ {x,y},p });
			}
			cout << sum << endl;
		}
	}
}


#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}
ll Power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2，判断b的奇偶性
			ans = ans * a % p; //如果为奇数，证明该位为1，需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
bool isprime(ll num)
{
	if (num == 2 || num == 3)
		return true;
	if (num % 6 != 1 && num % 6 != 5)
		return false;
	ll t = sqrt((double)num);
	for (ll i = 5; i <= t; i += 6)
		if (num % i == 0 || num % (i + 2) == 0)
			return false;
	return true;
}
bool isRunyear(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return true;
	}
	else {
		return false;
	}
}
ll n, m, i, j, k, t;
const ll INF = 1e5+10;
string s;
int main() {
	FAST_IO;
	while (cin >> k) {
		while (k--) {
			cin >> s;
			map<pair<ll, ll>,ll>mm;
			mm.clear();
			pair<ll, ll>p;
			p.first = p.second = 0;
			ll sum = 0;
			for (i = 0, j = s.length(); i < j; i++) {
				mm[p] = 1;
				if (s[i] == 'S')p.first--;
				if (s[i] == 'N')p.first++;
				if (s[i] == 'W')p.second--;
				if (s[i] == 'E')p.second++;
				if (mm[p] == 1)sum++;
				else sum += 5;
			}
			cout << sum << endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main()
{
	int t;
	cin >> t;
	cin.ignore(32767, '\n');
	for (int i = 0; i < t; i++) {
		int x = 0, y = 0, summ = 0;
		set<vector<int>> z;
		vector<int> b; // [x1, y1, x2, y2]  x1 <= x2, y1 <= y2
		char c[100001];
		cin >> c;
		for (int j = 0; j < strlen(c); j++) {
			b.clear();
			switch (c[j]) {
				case 'N':
				{
					b.push_back(x);
					b.push_back(y);
					b.push_back(x);
					b.push_back(y + 1);
					y++;
					break;
				}
				case 'S':
				{
					b.push_back(x);
					b.push_back(y - 1);
					b.push_back(x);
					b.push_back(y);
					y--;
					break;
				}
				case 'W':
				{
					b.push_back(x - 1);
					b.push_back(y);
					b.push_back(x);
					b.push_back(y);
					x--;
					break;
				}
				case 'E':
				{
					b.push_back(x);
					b.push_back(y);
					b.push_back(x + 1);
					b.push_back(y);
					x++;
					break;
				}
			}
			if (!(z.count(b) == false)) summ += 1;
			else {
				summ += 5;
				z.insert(b);
			}
		}
		std::cout << summ << endl;
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
using namespace std;
typedef struct dian {
	int x2,y2;
	int x1,y1;
	bool operator = (const dian b)const{
		if(this->x1==b.x1&&this->x2==b.x2&&this->y1==b.y1&&this->y2==b.y2) return true;
		else return true;
	}
	bool operator <(const dian b)const{
		if(x1==b.x1){
			if(x2==b.x2){
				if(y1==b.y1){
					return y2<b.y2;
				}
				return y1<b.y1;
			}
				return x2<b.x2;
		}
			return x1<b.x1;
	}
	friend ostream & operator <<(ostream &out,dian &a);
}dian;
 ostream & operator <<(ostream &out,dian &a){
		out<<a.x1<<endl;
		out<<a.y1<<endl;
		out<<a.x2<<endl;
		out<<a.y2<<endl;
		return out;
	}
int main(){
	int t;
	scanf("%d",&t);
      map<dian,int> ma;
	while(t--){
		char c[100000];
		scanf("%s",c);
		//printf("%s\n",c);
		int len = strlen(c);
		int x = 0,y=0;
		int num = 0;
		ma.clear();
		for(int i=0;i<len;i++){
			switch (c[i]){
				case 'N':{
					dian a;
					a.x1=x;
					a.y1=y;
					a.x2=x;
					a.y2=y+1;
				//	cout<<a<<endl;
					if(ma[a]==1){
						cout<<ma[a]<<endl;
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					y++;
					break;
				}
				case 'S':{
					dian a;
					a.x1=x;
					a.y1=y-1;
					a.x2=x;
					a.y2=y;
					cout<<a<<endl;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					y--;
					break;
				}
				case 'E':{
					dian a;
					a.x1=x;
					a.y1=y;
					a.x2=x+1;
					a.y2=y;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					x++;
					break;
				}
				case 'W':{
					dian a;
					a.x1=x-1;
					a.y1=y;
					a.x2=x;
					a.y2=y;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					x--;
					break;
				}
			}
		}
		printf("%d\n",num);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<string>
using namespace std;
typedef struct dian {
	int x2,y2;
	int x1,y1;
	bool operator = (const dian b)const{
		if(this->x1==b.x1&&this->x2==b.x2&&this->y1==b.y1&&this->y2==b.y2) return true;
		else return true;
	}
	bool operator <(const dian b)const{
		if(x1==b.x1){
			if(x2==b.x2){
				if(y1==b.y1){
					return y2<b.y2;
				}
				return y1<b.y1;
			}
				return x2<b.x2;
		}
			return x1<b.x1;
	}
	friend ostream & operator <<(ostream &out,dian &a);
}dian;
 ostream & operator <<(ostream &out,dian &a){
		out<<a.x1<<endl;
		out<<a.y1<<endl;
		out<<a.x2<<endl;
		out<<a.y2<<endl;
		return out;
	}
int main(){
	int t;
	scanf("%d",&t);
      map<dian,int> ma;
	while(t--){
		char c[1000000];
		scanf("%s",c);
		//printf("%s\n",c);
		int len = strlen(c);
		int x = 0,y=0;
		int num = 0;
		ma.clear();
		for(int i=0;i<len;i++){
			switch (c[i]){
				case 'N':{
					dian a;
					a.x1=x;
					a.y1=y;
					a.x2=x;
					a.y2=y+1;
				//	cout<<a<<endl;
					if(ma[a]==1){
				//		cout<<ma[a]<<endl;
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					y++;
					break;
				}
				case 'S':{
					dian a;
					a.x1=x;
					a.y1=y-1;
					a.x2=x;
					a.y2=y;
				//	cout<<a<<endl;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					y--;
					break;
				}
				case 'E':{
					dian a;
					a.x1=x;
					a.y1=y;
					a.x2=x+1;
					a.y2=y;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					x++;
					break;
				}
				case 'W':{
					dian a;
					a.x1=x-1;
					a.y1=y;
					a.x2=x;
					a.y2=y;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					x--;
					break;
				}
			}
		}
		printf("%d\n",num);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
using namespace std;
typedef struct dian {
	int x2,y2;
	int x1,y1;
	bool operator = (const dian b)const{
		if(this->x1==b.x1&&this->x2==b.x2&&this->y1==b.y1&&this->y2==b.y2) return true;
		else return true;
	}
	bool operator <(const dian b)const{
		if(x1==b.x1){
			if(x2==b.x2){
				if(y1==b.y1){
					return y2<b.y2;
				}
				return y1<b.y1;
			}
				return x2<b.x2;
		}
			return x1<b.x1;
	}
	friend ostream & operator <<(ostream &out,dian &a);
}dian;
 ostream & operator <<(ostream &out,dian &a){
		out<<a.x1<<endl;
		out<<a.y1<<endl;
		out<<a.x2<<endl;
		out<<a.y2<<endl;
		return out;
	}
int main(){
	int t;
	scanf("%d",&t);
      map<dian,int> ma;
	while(t--){
		char c[10000];
		scanf("%s",c);
		//printf("%s\n",c);
		int len = strlen(c);
		int x = 0,y=0;
		int num = 0;
		ma.clear();
		for(int i=0;i<len;i++){
			switch (c[i]){
				case 'N':{
					dian a;
					a.x1=x;
					a.y1=y;
					a.x2=x;
					a.y2=y+1;
				//	cout<<a<<endl;
					if(ma[a]==1){
				//		cout<<ma[a]<<endl;
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					y++;
					break;
				}
				case 'S':{
					dian a;
					a.x1=x;
					a.y1=y-1;
					a.x2=x;
					a.y2=y;
				//	cout<<a<<endl;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					y--;
					break;
				}
				case 'E':{
					dian a;
					a.x1=x;
					a.y1=y;
					a.x2=x+1;
					a.y2=y;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					x++;
					break;
				}
				case 'W':{
					dian a;
					a.x1=x-1;
					a.y1=y;
					a.x2=x;
					a.y2=y;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					x--;
					break;
				}
			}
		}
		printf("%d\n",num);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
using namespace std;
typedef struct dian {
	int x2,y2;
	int x1,y1;
	bool operator = (const dian b)const{
		if(this->x1==b.x1&&this->x2==b.x2&&this->y1==b.y1&&this->y2==b.y2) return true;
		else return true;
	}
	bool operator <(const dian b)const{
		if(x1==b.x1){
			if(x2==b.x2){
				if(y1==b.y1){
					return y2<b.y2;
				}
				return y1<b.y1;
			}
				return x2<b.x2;
		}
			return x1<b.x1;
	}
	friend ostream & operator <<(ostream &out,dian &a);
}dian;
 ostream & operator <<(ostream &out,dian &a){
		out<<a.x1<<endl;
		out<<a.y1<<endl;
		out<<a.x2<<endl;
		out<<a.y2<<endl;
		return out;
	}
int main(){
	int t;
	scanf("%d",&t);
      map<dian,int> ma;
	while(t--){
		char c[200];
		scanf("%s",c);
		//printf("%s\n",c);
		int len = strlen(c);
		int x = 0,y=0;
		int num = 0;
		ma.clear();
		for(int i=0;i<len;i++){
			switch (c[i]){
				case 'N':{
					dian a;
					a.x1=x;
					a.y1=y;
					a.x2=x;
					a.y2=y+1;
				//	cout<<a<<endl;
					if(ma[a]==1){
					//	cout<<ma[a]<<endl;
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					y++;
					break;
				}
				case 'S':{
					dian a;
					a.x1=x;
					a.y1=y-1;
					a.x2=x;
					a.y2=y;
				//	cout<<a<<endl;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					y--;
					break;
				}
				case 'E':{
					dian a;
					a.x1=x;
					a.y1=y;
					a.x2=x+1;
					a.y2=y;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					x++;
					break;
				}
				case 'W':{
					dian a;
					a.x1=x-1;
					a.y1=y;
					a.x2=x;
					a.y2=y;
					if(ma[a]==1){
						num++;
					}else{
						ma[a]=1;
						num+=5;
					}
					x--;
					break;
				}
			}
		}
		printf("%d\n",num);
	}
	return 0;
}


t = int(input())

for tt in range(0,t):
    direction = input()
    x,y=0,0
    path = 0
    l=set()

    for d in direction:
        if d=="N":
            x+=1
            toappend=(x-1,y,x,y)
            ttoappend=(x,y,x-1,y)
        elif d=="S":
            x-=1
            toappend=(x+1,y,x,y)
            ttoappend=(x,y,x+1,y)
        elif d=="E":
            y+=1
            toappend=(x,y-1,x,y)
            ttoappend=(x,y,x,y-1)
        elif d=="W":
            y-=1
            toappend=(x,y+1,x,y)
            ttoappend=(x,y,x,y+1)
        if (toappend not in l) or (ttoappend not in l):
            path+=5
            l.add(toappend)
            l.add(ttoappend)
        else:
            path+=1

    print(path)


t = int(input())

for tt in range(0,t):
    direction = input()
    x,y=0,0
    path = 0
    l=[]
    flag = 0

    for d in direction:
        if d=="N":
            x+=1
            toappend=[x-1,y,x,y]
            ttoappend=[x,y,x-1,y]
        elif d=="S":
            x-=1
            toappend=[x+1,y,x,y]
            ttoappend=[x,y,x+1,y]
        elif d=="E":
            y+=1
            toappend=[x,y-1,x,y]
            ttoappend=[x,y,x,y-1]
        elif d=="W":
            y-=1
            toappend=[x,y+1,x,y]
            ttoappend=[x,y,x,y+1]
        if (toappend not in l) or (ttoappend not in l):
            path+=5
            l.append(toappend)
            l.append(ttoappend)
        else:
            path+=1

    print(path)


t = int(input())

for tt in range(0,t):
    direction = input()
    x,y=0,0
    path = 0
    l=[[0,0]]
    for d in direction:
        if d=="N":
            x+=1
        elif d=="S":
            x-=1
        elif d=="E":
            y+=1
        elif d=="W":
            y-=1
        for i,j in l:
            if x==i and y==j:
                path+=1
                break
        else:
            path+=5
            a=[]
            a.append(x)
            a.append(y)
            l.append(a)
    print(path)


for i in range(int(input())):
    way = input()
    ans = 0
    pt0 = (0, 0)
    tracks = set()
    for direct in way:
        if direct == 'N':
            pt1 = (pt0[0], pt0[1] + 1)
        elif direct == 'S':
            pt1 = (pt0[0], pt0[1] - 1)
        elif direct == 'E':
            pt1 = (pt0[0] + 1, pt0[1])
        elif direct == 'W':
            pt1 = (pt0[0] - 1, pt0[1])

        if (pt0, pt1) in tracks:
            ans += 1
        else:
            ans += 5
        tracks.add((pt0, pt1))
        tracks.add((pt1, pt0))
        pt0 = pt1

    print(int(ans))


import re

rstring = r"(NNNWSEN)*"

for i in range(int(input())):
    way = input()
    ans = 0
    pt0 = (0, 0)
    tracks = []
    if len(set(way)) == 1:
        ans = len(way) * 5
    elif re.fullmatch(rstring, way):
        ans = (len(way) / 7) * 31
    else:
        for direct in way:
            if direct == 'N':
                pt1 = (pt0[0], pt0[1] + 1)
            elif direct == 'S':
                pt1 = (pt0[0], pt0[1] - 1)
            elif direct == 'E':
                pt1 = (pt0[0] + 1, pt0[1])
            elif direct == 'W':
                pt1 = (pt0[0] - 1, pt0[1])

            if (pt0, pt1) in tracks or (pt1, pt0) in tracks:
                ans += 1
            else:
                ans += 5
            tracks.append((pt0, pt1))
            pt0 = pt1

    print(ans)


import re

rstring = r"(NNNWSEN)*"

for i in range(int(input())):
    way = input()
    ans = 0
    pt0 = (0, 0)
    tracks = []
    if len(set(way)) == 1:
        ans = len(way) * 5
    elif re.fullmatch(rstring, way):
        ans = (len(way) / 7) * 31
    else:
        for direct in way:
            if direct == 'N':
                pt1 = (pt0[0], pt0[1] + 1)
            elif direct == 'S':
                pt1 = (pt0[0], pt0[1] - 1)
            elif direct == 'E':
                pt1 = (pt0[0] + 1, pt0[1])
            elif direct == 'W':
                pt1 = (pt0[0] - 1, pt0[1])

            if (pt0, pt1) in tracks or (pt1, pt0) in tracks:
                ans += 1
            else:
                ans += 5
            tracks.append((pt0, pt1))
            pt0 = pt1

    print(int(ans))