#include <bits/stdc++.h>
using namespace std;
const int oo = 0x7fffffff;

int n, k, f[50005][505], x, y, par[505];
vector<int> a[50005];
long long ans = 0;

void dfs(int u, int pa) {
    f[u][0] = 1;
    par[u] = pa;
    for (int i = 0; i < a[u].size(); ++i) {
        if (a[u][i] == pa)
            continue;
        dfs(a[u][i], u);
        for (int j = 0; j < k; ++j)
            f[u][j + 1] += f[a[u][i]][j];
    }
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i + 1 < n; ++i) {
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }

    dfs(1, 0);

    for (int u = 1; u <= n; ++u) {
        ans += f[u][k];
        for (int i = 0; i < a[u].size(); ++i) {
            int v = a[u][i];
            if (v == par[u])
                continue;
            for (int d = 1; d < k; ++d)
                ans += f[v][d] * 1LL * (f[u][k - d] - f[v][k - d - 1]);

        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int oo = 0x7fffffff;

int n, k, f[50005][505], x, y, par[505];
vector<int> a[50005];
long long ans = 0;

void dfs(int u, int pa) {
    f[u][0] = 1;
    par[u] = pa;
    for (int i = 0; i < a[u].size(); ++i) {
        if (a[u][i] == pa)
            continue;
        dfs(a[u][i], u);
        for (int j = 0; j < k; ++j)
            f[u][j + 1] += f[a[u][i]][j];
    }
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i + 1 < n; ++i) {
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }

    dfs(1, 0);
    for (int u = 1; u <= n; ++u) {
        ans += f[u][k] * 2;
        for (int i = 0; i < a[u].size(); ++i) {
            int v = a[u][i];
            if (v == par[u])
                continue;
            for (int d = 1; d < k; ++d) {
                ans += f[v][d - 1] * 1LL * (f[u][k - d] - f[v][k - d - 1]);
//                cout << u << ' ' << v << ' ' << f[v][d - 1] * 1LL * (f[u][k - d] - f[v][k - d - 1]) << endl;
            }
        }
    }
    cout << ans / 2;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int oo = 0x7fffffff;

int n, k, x, y, par[505];
long long f[50005][505];
vector<int> a[50005];
long long ans = 0;

void dfs(int u, int pa) {
    f[u][0] = 1;
    par[u] = pa;
    for (int i = 0; i < a[u].size(); ++i) {
        if (a[u][i] == pa)
            continue;
        dfs(a[u][i], u);
        for (int j = 0; j < k; ++j)
            f[u][j + 1] += f[a[u][i]][j];
    }
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i + 1 < n; ++i) {
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }

    dfs(1, 0);
    for (int u = 1; u <= n; ++u) {
        ans += f[u][k] * 1LL * 2;
        for (int i = 0; i < a[u].size(); ++i) {
            int v = a[u][i];
            if (v == par[u])
                continue;
            for (int d = 1; d < k; ++d) {
                ans += f[v][d - 1] * 1LL * (f[u][k - d] - f[v][k - d - 1]);
//                cout << u << ' ' << v << ' ' << f[v][d - 1] * 1LL * (f[u][k - d] - f[v][k - d - 1]) << endl;
            }
        }
    }
    cout << ans / 2;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int oo = 0x7fffffff;

int n, k, f[50005][505], x, y;
vector<int> a[50005];
long long ans = 0;

void dfs(int u, int par) {
    f[u][0] = 1;
    for (int i = 0; i < a[u].size(); ++i) {
        if (a[u][i] == par)
            continue;
        dfs(a[u][i], u);
        for (int j = 0; j < k; ++j)
            ans += f[a[u][i]][j] * 1LL * f[u][k - j - 1];
        for (int j = 0; j < k; ++j)
            f[u][j + 1] += f[a[u][i]][j];
    }
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i + 1 < n; ++i) {
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1, 0);
    cout << ans;
    return 0;
}


//This code was writen by Alexander Dryapko (sdryapko)
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#define gcd(a,b) __gcd((a),(b));
#define sqr(a) ((a)*(a))
#define odd(a) ((a)&1)
#define pw2(x) (1ll<<(x))
#define F first
#define S second
const int maxi=2000000000;
const int maxq=1000000000;
const double eps=1e-10;
const double pi=3.1415926535897932;
const double inf=1e+18;
const int mo=1000000007;

using namespace std;
long long ans;
int y[111111],tin[111111],p[111111],kolr,s,nom[111111],up[555][50011],down[555][50011],a,b,n,k,lis[111111];
bool f[111111];
void dfs(int x,int s) {

	if (f[x]) return;
	tin[x]=s;
	f[x]=true;
	int q=nom[x];
	down[0][x]=1;
	while (q) {
		if (f[y[q]]==false) {
			dfs(y[q],s+1);
			for (int i=1;i<=k;i++) down[i][x]+=down[i-1][y[q]];
		}
		q=p[q];
	}
}
void dfs1(int x,int pred) {
	s--;
	int q=nom[x];
	ans=ans+down[s][x];
	if (s) ans-=down[s-1][pred];
	while (q) {
		if (tin[y[q]]<=tin[x]&&y[q]!=pred&&s) dfs1(y[q],x);
	 	q=p[q];
	}
	s++;
}
void adde(int a,int b) {
	kolr++;
	y[kolr]=b;
	p[kolr]=nom[a];
	nom[a]=kolr;
}
int main(){
       // freopen("input.txt","r",stdin);
       // freopen("output.txt","w",stdout);
        scanf("%d %d",&n,&k);
        for (int i=0;i<n-1;i++) {
        	scanf("%d%d",&a,&b);
        	adde(a,b);
        	adde(b,a);
  	}
        dfs(1,0);
        s=k+1;
        for (int i=1;i<=n;i++) dfs1(i,0);

        cout<<ans/2<<endl;
       	return 0;
}


//This code was writen by Alexander Dryapko (sdryapko)
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#define gcd(a,b) __gcd((a),(b));
#define sqr(a) ((a)*(a))
#define odd(a) ((a)&1)
#define pw2(x) (1ll<<(x))
#define F first
#define S second
const int maxi=2000000000;
const int maxq=1000000000;
const double eps=1e-10;
const double pi=3.1415926535897932;
const double inf=1e+18;
const int mo=1000000007;

using namespace std;
long long ans;
int y[1111111],tin[111111],p[1111111],kolr,nom[1111111],up[555][50011],down[555][50011],a,b,n,k,lis[111111];
bool f[1111111];
void dfs(int x,int s) {

	if (f[x]) return;
	tin[x]=s;
	f[x]=true;
	int q=nom[x];
	down[0][x]=1;
	while (q) {
		if (f[y[q]]==false) {
			dfs(y[q],s+1);
			for (int i=1;i<=k;i++) down[i][x]+=down[i-1][y[q]];
		}
		q=p[q];
	}
}
void dfs1(int x,int pred,int s) {
	int q=nom[x];
	ans=ans+down[s][x]-down[s-1][pred];

	while (q) {
		if (tin[y[q]]<=tin[x]&&y[q]!=pred&&s) dfs1(y[q],x,s-1);
	 	q=p[q];
	}
}
void adde(int a,int b) {
	kolr++;
	y[kolr]=b;
	p[kolr]=nom[a];
	nom[a]=kolr;
}
int main(){
       // freopen("input.txt","r",stdin);
       // freopen("output.txt","w",stdout);
        scanf("%d %d",&n,&k);
        for (int i=0;i<n-1;i++) {
        	scanf("%d%d",&a,&b);
        	adde(a,b);
        	adde(b,a);
  	}
        dfs(1,0);
        for (int i=1;i<=n;i++) dfs1(i,0,k);
        cout<<ans/2<<endl;
       	return 0;
}


//This code was writen by Alexander Dryapko (sdryapko)
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#define gcd(a,b) __gcd((a),(b));
#define sqr(a) ((a)*(a))
#define odd(a) ((a)&1)
#define pw2(x) (1ll<<(x))
#define F first
#define S second
const int maxi=2000000000;
const int maxq=1000000000;
const double eps=1e-10;
const double pi=3.1415926535897932;
const double inf=1e+18;
const int mo=1000000007;

using namespace std;
long long ans;
int pred,y[111111],tin[111111],p[111111],kolr,s,nom[111111],down[501][50011],a[80000],b[80000],n,k,lis[111111];
bool f[111111];
void dfs(int x,int s) {

	if (f[x]) return;
	tin[x]=s;
	f[x]=true;
	int q=nom[x];
	down[0][x]=1;
	while (q) {
		if (f[y[q]]==false) {
			dfs(y[q],s+1);
			for (int i=1;i<=k;i++) down[i][x]+=down[i-1][y[q]];
		}
		q=p[q];
	}
}
void dfs1(int x,int pred) {

        s--;
	int q=nom[x];
	ans=ans+down[s][x];

	if (s) ans-=down[s-1][pred];
	if (s) while (q) {
		if (tin[y[q]]<tin[x]) dfs1(y[q],x);
	 	q=p[q];
	}
	s++;
}
void adde(int a,int b) {
	kolr++;
	y[kolr]=b;
	p[kolr]=nom[a];
	nom[a]=kolr;
}
int main(){
//        freopen("input.txt","r",stdin);
//        freopen("output.txt","w",stdout);
        scanf("%d %d",&n,&k);
        for (int i=0;i<n-1;i++) {
        	scanf("%d%d",&a[i],&b[i]);
        	adde(a[i],b[i]);
        	adde(b[i],a[i]);
  	}
        dfs(1,0);
        s=k+1;

        kolr=0;
        for (int i=0;i<=n;i++) nom[i]=0;
        for (int i=0;i<n-1;i++) {
        	if (tin[a[i]]>tin[b[i]]) adde(a[i],b[i]); else adde(b[i],a[i]);
        }
	for (int i=1;i<=n;i++) {
        	dfs1(i,0);
        }
        cout<<ans/2<<endl;
       	return 0;
}


//This code was writen by Alexander Dryapko (sdryapko)
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#define gcd(a,b) __gcd((a),(b));
#define sqr(a) ((a)*(a))
#define odd(a) ((a)&1)
#define pw2(x) (1ll<<(x))
#define F first
#define S second
const int maxi=2000000000;
const int maxq=1000000000;
const double eps=1e-10;
const double pi=3.1415926535897932;
const double inf=1e+18;
const int mo=1000000007;

using namespace std;
long long ans;
int y[111111],tin[111111],p[111111],kolr,nom[111111],up[555][50011],down[555][50011],a,b,n,k,lis[111111];
bool f[111111];
void dfs(int x,int s) {

	if (f[x]) return;
	tin[x]=s;
	f[x]=true;
	int q=nom[x];
	down[0][x]=1;
	while (q) {
		if (f[y[q]]==false) {
			dfs(y[q],s+1);
			for (int i=1;i<=k;i++) down[i][x]+=down[i-1][y[q]];
		}
		q=p[q];
	}
}
void dfs1(int x,int pred,int s) {
	int q=nom[x];
	ans=ans+down[s][x];
	if (s) ans-=down[s-1][pred];

	while (q) {
		if (tin[y[q]]<=tin[x]&&y[q]!=pred&&s) dfs1(y[q],x,s-1);
	 	q=p[q];
	}
}
void adde(int a,int b) {
	kolr++;
	y[kolr]=b;
	p[kolr]=nom[a];
	nom[a]=kolr;
}
int main(){
       // freopen("input.txt","r",stdin);
       // freopen("output.txt","w",stdout);
        scanf("%d %d",&n,&k);
        for (int i=0;i<n-1;i++) {
        	scanf("%d%d",&a,&b);
        	adde(a,b);
        	adde(b,a);
  	}
        dfs(1,0);
        for (int i=1;i<=n;i++) dfs1(i,0,k);
        cout<<ans/2<<endl;
       	return 0;
}


//This code was writen by Alexander Dryapko (sdryapko)
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#define gcd(a,b) __gcd((a),(b));
#define sqr(a) ((a)*(a))
#define odd(a) ((a)&1)
#define pw2(x) (1ll<<(x))
#define F first
#define S second
const int maxi=2000000000;
const int maxq=1000000000;
const double eps=1e-10;
const double pi=3.1415926535897932;
const double inf=1e+18;
const int mo=1000000007;

using namespace std;
long long ans;
int pred,y[111111],tin[111111],p[111111],kolr,s,nom[111111],down[50011][501],a,b,n,k,lis[111111];
bool f[111111];
void dfs(int x,int s) {

	if (f[x]) return;
	tin[x]=s;
	f[x]=true;
	int q=nom[x];
	down[x][0]=1;
	while (q) {
		if (f[y[q]]==false) {
			dfs(y[q],s+1);
			for (int i=1;i<=k;i++) down[x][i]+=down[y[q]][i-1];
		}
		q=p[q];
	}
}
void dfs1(int x,int pred) {

        s--;
	int q=nom[x];
	ans=ans+down[x][s];
	if (s) ans-=down[pred][s-1];

	if (s) while (q) {

		if (tin[y[q]]<=tin[x]) dfs1(y[q],x);
	 	q=p[q];
	}
	s++;
}
void adde(int a,int b) {
	kolr++;
	y[kolr]=b;
	p[kolr]=nom[a];
	nom[a]=kolr;
}
int main(){
     //   freopen("input.txt","r",stdin);
     //   freopen("output.txt","w",stdout);
        scanf("%d %d",&n,&k);
        for (int i=0;i<n-1;i++) {
        	scanf("%d%d",&a,&b);
        	adde(a,b);
        	adde(b,a);
  	}
        dfs(1,0);
        s=k+1;
        pred=0;
        for (int i=1;i<=n;i++) dfs1(i,0);

        cout<<ans/2<<endl;
       	return 0;
}


//This code was writen by Alexander Dryapko (sdryapko)
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#define gcd(a,b) __gcd((a),(b));
#define sqr(a) ((a)*(a))
#define odd(a) ((a)&1)
#define pw2(x) (1ll<<(x))
#define F first
#define S second
const int maxi=2000000000;
const int maxq=1000000000;
const double eps=1e-10;
const double pi=3.1415926535897932;
const double inf=1e+18;
const int mo=1000000007;

using namespace std;
long long ans;
int y[111111],tin[111111],p[111111],kolr,s,nom[111111],up[555][50011],down[555][50011],a,b,n,k,lis[111111];
bool f[111111];
void dfs(int x,int s) {

	if (f[x]) return;
	tin[x]=s;
	f[x]=true;
	int q=nom[x];
	down[0][x]=1;
	while (q) {
		if (f[y[q]]==false) {
			dfs(y[q],s+1);
			for (int i=1;i<=k;i++) down[i][x]+=down[i-1][y[q]];
		}
		q=p[q];
	}
}
void dfs1(int x,int pred) {
	int q=nom[x];
	ans=ans+down[s][x];
	s--;
	if (s) ans-=down[s-1][pred];

	while (q) {
		if (tin[y[q]]<=tin[x]&&y[q]!=pred&&s) dfs1(y[q],x);

	 	q=p[q];
	}
	s++;
}
void adde(int a,int b) {
	kolr++;
	y[kolr]=b;
	p[kolr]=nom[a];
	nom[a]=kolr;
}
int main(){
       // freopen("input.txt","r",stdin);
       // freopen("output.txt","w",stdout);
        scanf("%d %d",&n,&k);
        for (int i=0;i<n-1;i++) {
        	scanf("%d%d",&a,&b);
        	adde(a,b);
        	adde(b,a);
  	}
        dfs(1,0);
        s=k;
        for (int i=1;i<=n;i++) dfs1(i,0);

        cout<<ans/2<<endl;
       	return 0;
}


//This code was writen by Alexander Dryapko (sdryapko)
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#define gcd(a,b) __gcd((a),(b));
#define sqr(a) ((a)*(a))
#define odd(a) ((a)&1)
#define pw2(x) (1ll<<(x))
#define F first
#define S second
const int maxi=2000000000;
const int maxq=1000000000;
const double eps=1e-10;
const double pi=3.1415926535897932;
const double inf=1e+18;
const int mo=1000000007;

using namespace std;
long long ans;
int y[1111111],tin[111111],p[1111111],kolr,nom[1111111],up[555][50011],down[555][50011],a,b,n,k,lis[111111];
bool f[1111111];
void dfs(int x,int s) {

	if (f[x]) return;
	tin[x]=s;
	f[x]=true;
	int q=nom[x];
	down[0][x]=1;
	while (q) {
		if (f[y[q]]==false) {
			dfs(y[q],s+1);
			for (int i=1;i<=k;i++) down[i][x]+=down[i-1][y[q]];
		}
		q=p[q];
	}
}
void dfs1(int x,int pred,int s) {
	int q=nom[x];
	ans=ans+down[s][x];
	if (s) ans-=down[s-1][pred];

	while (q) {
		if (tin[y[q]]<=tin[x]&&y[q]!=pred&&s) dfs1(y[q],x,s-1);
	 	q=p[q];
	}
}
void adde(int a,int b) {
	kolr++;
	y[kolr]=b;
	p[kolr]=nom[a];
	nom[a]=kolr;
}
int main(){
       // freopen("input.txt","r",stdin);
       // freopen("output.txt","w",stdout);
        scanf("%d %d",&n,&k);
        for (int i=0;i<n-1;i++) {
        	scanf("%d%d",&a,&b);
        	adde(a,b);
        	adde(b,a);
  	}
        dfs(1,0);
        for (int i=1;i<=n;i++) dfs1(i,0,k);
        cout<<ans/2<<endl;
       	return 0;
}


//This code was writen by Alexander Dryapko (sdryapko)
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#define gcd(a,b) __gcd((a),(b));
#define sqr(a) ((a)*(a))
#define odd(a) ((a)&1)
#define pw2(x) (1ll<<(x))
#define F first
#define S second
const int maxi=2000000000;
const int maxq=1000000000;
const double eps=1e-10;
const double pi=3.1415926535897932;
const double inf=1e+18;
const int mo=1000000007;

using namespace std;
long long ans;
int y[111111],tin[111111],p[111111],kolr,s,nom[111111],up[555][50011],down[555][50011],a,b,n,k,lis[111111];
bool f[111111];
void dfs(int x,int s) {

	if (f[x]) return;
	tin[x]=s;
	f[x]=true;
	int q=nom[x];
	down[0][x]=1;
	while (q) {
		if (f[y[q]]==false) {
			dfs(y[q],s+1);
			for (int i=1;i<=k;i++) down[i][x]+=down[i-1][y[q]];
		}
		q=p[q];
	}
}
void dfs1(int x,int pred) {
	int q=nom[x];
	ans=ans+down[s][x];
	s--;
	if (s) ans-=down[s-1][pred];

	while (q) {
		if (tin[y[q]]<=tin[x]&&y[q]!=pred&&s) dfs1(y[q],x,s);

	 	q=p[q];
	}
	s++;
}
void adde(int a,int b) {
	kolr++;
	y[kolr]=b;
	p[kolr]=nom[a];
	nom[a]=kolr;
}
int main(){
       // freopen("input.txt","r",stdin);
       // freopen("output.txt","w",stdout);
        scanf("%d %d",&n,&k);
        for (int i=0;i<n-1;i++) {
        	scanf("%d%d",&a,&b);
        	adde(a,b);
        	adde(b,a);
  	}
        dfs(1,0);
        s=k;
        for (int i=1;i<=n;i++) dfs1(i,0);

        cout<<ans/2<<endl;
       	return 0;
}


//This code was writen by Alexander Dryapko (sdryapko)
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#define gcd(a,b) __gcd((a),(b));
#define sqr(a) ((a)*(a))
#define odd(a) ((a)&1)
#define pw2(x) (1ll<<(x))
#define F first
#define S second
const int maxi=2000000000;
const int maxq=1000000000;
const double eps=1e-10;
const double pi=3.1415926535897932;
const double inf=1e+18;
const int mo=1000000007;

using namespace std;
long long ans;
int y[111111],tin[111111],p[111111],kolr,s,nom[111111],up[555][50011],down[555][50011],a,b,n,k,lis[111111];
bool f[111111];
void dfs(int x,int s) {

	if (f[x]) return;
	tin[x]=s;
	f[x]=true;
	int q=nom[x];
	down[0][x]=1;
	while (q) {
		if (f[y[q]]==false) {
			dfs(y[q],s+1);
			for (int i=1;i<=k;i++) down[i][x]+=down[i-1][y[q]];
		}
		q=p[q];
	}
}
void dfs1(int x,int pred) {
	int q=nom[x];
	s--;
	ans=ans+down[s][x];
	if (s) ans-=down[s-1][pred];
	while (q) {
		if (tin[y[q]]<=tin[x]&&y[q]!=pred&&s) dfs1(y[q],x);
	 	q=p[q];
	}
	s++;
}
void adde(int a,int b) {
	kolr++;
	y[kolr]=b;
	p[kolr]=nom[a];
	nom[a]=kolr;
}
int main(){
       // freopen("input.txt","r",stdin);
       // freopen("output.txt","w",stdout);
        scanf("%d %d",&n,&k);
        for (int i=0;i<n-1;i++) {
        	scanf("%d%d",&a,&b);
        	adde(a,b);
        	adde(b,a);
  	}
        dfs(1,0);
        s=k;
        for (int i=1;i<=n;i++) dfs1(i,0);

        cout<<ans/2<<endl;
       	return 0;
}


//This code was writen by Alexander Dryapko (sdryapko)
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#define gcd(a,b) __gcd((a),(b));
#define sqr(a) ((a)*(a))
#define odd(a) ((a)&1)
#define pw2(x) (1ll<<(x))
#define F first
#define S second
const int maxi=2000000000;
const int maxq=1000000000;
const double eps=1e-10;
const double pi=3.1415926535897932;
const double inf=1e+18;
const int mo=1000000007;

using namespace std;
long long ans;
int y[111111],tin[111111],p[111111],kolr,s,nom[111111],up[555][50011],down[555][50011],a,b,n,k,lis[111111];
bool f[111111];
void dfs(int x,int s) {

	if (f[x]) return;
	tin[x]=s;
	f[x]=true;
	int q=nom[x];
	down[0][x]=1;
	while (q) {
		if (f[y[q]]==false) {
			dfs(y[q],s+1);
			for (int i=1;i<=k;i++) down[i][x]+=down[i-1][y[q]];
		}
		q=p[q];
	}
}
void dfs1(int x,int pred) {
	int q=nom[x];
	ans=ans+down[s][x];
	if (s) ans-=down[s-1][pred];
	s--;
	while (q) {
		if (tin[y[q]]<=tin[x]&&y[q]!=pred&&s) dfs1(y[q],x);

	 	q=p[q];
	}
	s++;
}
void adde(int a,int b) {
	kolr++;
	y[kolr]=b;
	p[kolr]=nom[a];
	nom[a]=kolr;
}
int main(){
       // freopen("input.txt","r",stdin);
       // freopen("output.txt","w",stdout);
        scanf("%d %d",&n,&k);
        for (int i=0;i<n-1;i++) {
        	scanf("%d%d",&a,&b);
        	adde(a,b);
        	adde(b,a);
  	}
        dfs(1,0);
        s=k;
        for (int i=1;i<=n;i++) dfs1(i,0);

        cout<<ans/2<<endl;
       	return 0;
}


#include <bits/stdc++.h>

using namespace std ;

#define PB  push_back
#define L   first
#define R   second

const int maxn = 5e4 + 10 , maxk = 500 + 10 ;
long long dp[maxn][maxk] , h[maxn] ;
bool mark[maxn] ;
vector <int> adj[maxn] ;

void dfs(int x , int k)
{
	mark[x] = true ;
	for(int i = 0 ; i < adj[x].size() ; i++){
		int child = adj[x][i] ;
		if(!mark[child]){
			h[child] = h[x] + 1 ;
			dp[x][k] += dp[child][k - 1] ;
			dfs(child , k) ;
		}
	}
}

int main()
{
	long long ans = 0 ;
	int n , k ;
	cin >> n >> k ;
	for(int i = 1 ; i <= n - 1 ; i++){
		int fi , se ;
		cin >> fi >> se ;
		adj[fi].PB(se) ;
		adj[se].PB(fi) ;
	}
	dp[1][1] = 0 ;
	for(int i = 2 ; i <= n ; i++)
		dp[i][1] = adj[i].size() - 1 ;
	for(int i = 2 ; i <= k ; i++){
		memset(mark , false , sizeof mark) ;
		dfs(1 , i) ;
	}
	for(int i = 1 ; i < k ; i++){
		for(int j = 1 ; j <= n ; j++){
			for(int p = 0 ; p < adj[j].size() ; p++){
				int child = adj[j][p] ;
				if(h[child] < h[j])
					continue ;
				if(i == 1)
					ans += (dp[j][k - i] - dp[child][k - i - 1]) / 2 ;
				else
					ans += dp[child][i - 1] * (dp[j][k - i] - dp[child][k - i - 1]) / 2 ;
			}
		}
	}
	ans /= 2 ;
	for(int i = 1 ; i <= n ; i++)
		ans += dp[i][k] ;
	cout << ans << endl ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std ;

#define PB  push_back
#define L   first
#define R   second

const int maxn = 5e4 + 10 , maxk = 500 + 10 ;
long long dp[maxn][maxk] , h[maxn] ;
bool mark[maxn] ;
vector <int> adj[maxn] ;

void dfs(int x , int k)
{
	mark[x] = true ;
	for(int i = 0 ; i < adj[x].size() ; i++){
		int child = adj[x][i] ;
		if(!mark[child]){
			h[child] = h[x] + 1 ;
			dp[x][k] += dp[child][k - 1] ;
			dfs(child , k) ;
		}
	}
}

int main()
{
	cin.tie(0) ;
	long long ans = 0 ;
	int n , k ;
	cin >> n >> k ;
	for(int i = 1 ; i <= n - 1 ; i++){
		int fi , se ;
		cin >> fi >> se ;
		adj[fi].PB(se) ;
		adj[se].PB(fi) ;
	}
	dp[1][1] = adj[1].size() ;
	for(int i = 1 ; i <= n ; i++)
		dp[i][0] = 1 ;
	for(int i = 2 ; i <= n ; i++)
		dp[i][1] = adj[i].size() - 1 ;
	for(int i = 2 ; i <= k ; i++){
		memset(mark , false , sizeof mark) ;
		dfs(1 , i) ;
	}
	for(int i = 1 ; i < k ; i++){
		for(int j = 1 ; j <= n ; j++){
			for(int p = 0 ; p < adj[j].size() ; p++){
				int child = adj[j][p] ;
				if(h[child] < h[j])
					continue ;
					ans += dp[child][i - 1] * (dp[j][k - i] - dp[child][k - i - 1]) ;
			}
		}
	}
	ans /= 2 ;
	for(int i = 1 ; i <= n ; i++)
		ans += dp[i][k] ;
	cout << ans << endl ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std ;

#define PB  push_back
#define L   first
#define R   second

const int maxn = 5e4 + 10 , maxk = 500 + 10 ;
long long dp[maxn][maxk] , h[maxn] ;
vector <int> adj[maxn] ;

void dfs(int x , int par , int k)
{
	for(int i = 0 ; i < adj[x].size() ; i++){
		int child = adj[x][i] ;
		if(child != par){
			h[child] = h[x] + 1 ;
			dp[x][k] += dp[child][k - 1] ;
			dfs(child , x , k) ;
		}
	}
}

int main()
{
	cin.tie(0) ;
	long long ans = 0 ;
	int n , k ;
	cin >> n >> k ;
	for(int i = 1 ; i <= n - 1 ; i++){
		int fi , se ;
		cin >> fi >> se ;
		adj[fi].PB(se) ;
		adj[se].PB(fi) ;
	}
	dp[1][1] = adj[1].size() ;
	for(int i = 1 ; i <= n ; i++)
		dp[i][0] = 1 ;
	for(int i = 2 ; i <= n ; i++)
		dp[i][1] = adj[i].size() - 1 ;
	for(int i = 2 ; i <= k ; i++)
		dfs(1 , 0 , i) ;
	for(int i = 1 ; i < k ; i++){
		for(int j = 1 ; j <= n ; j++){
			for(int p = 0 ; p < adj[j].size() ; p++){
				int child = adj[j][p] ;
				if(h[child] < h[j])
					continue ;
				ans += dp[child][i - 1] * (dp[j][k - i] - dp[child][k - i - 1]) ;
			}
		}
	}
	ans /= 2 ;
	for(int i = 1 ; i <= n ; i++)
		ans += dp[i][k] ;
	cout << ans << endl ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std ;

#define PB  push_back
#define L   first
#define R   second

const int maxn = 5e4 + 10 , maxk = 500 + 10 ;
long long dp[maxn][maxk] , h[maxn] ;
bool mark[maxn] ;
vector <int> adj[maxn] ;

void dfs(int x , int k)
{
	mark[x] = true ;
	for(int i = 0 ; i < adj[x].size() ; i++){
		int child = adj[x][i] ;
		if(!mark[child]){
			h[child] = h[x] + 1 ;
			dp[x][k] += dp[child][k - 1] ;
			dfs(child , k) ;
		}
	}
}

int main()
{
	long long ans = 0 ;
	int n , k ;
	cin >> n >> k ;
	for(int i = 1 ; i <= n - 1 ; i++){
		int fi , se ;
		cin >> fi >> se ;
		adj[fi].PB(se) ;
		adj[se].PB(fi) ;
	}
	dp[1][1] = adj[1].size() ;
	for(int i = 2 ; i <= n ; i++)
		dp[i][1] = adj[i].size() - 1 ;
	for(int i = 2 ; i <= k ; i++){
		memset(mark , false , sizeof mark) ;
		dfs(1 , i) ;
	}
	for(int i = 1 ; i < k ; i++){
		for(int j = 1 ; j <= n ; j++){
			for(int p = 0 ; p < adj[j].size() ; p++){
				int child = adj[j][p] ;
				if(h[child] < h[j])
					continue ;
				if(i == 1)
					ans += (dp[j][k - i] - dp[child][k - i - 1]) / 2 ;
				else
					ans += dp[child][i - 1] * (dp[j][k - i] - dp[child][k - i - 1]) / 2 ;
			}
		}
	}
	ans /= 2 ;
	for(int i = 1 ; i <= n ; i++)
		ans += dp[i][k] ;
	cout << ans << endl ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std;

const int MAX = 1e9;

int n;

vector <int> g[1001];

bool used[1001];

int query(int a, int b);

bool check()
{
    for(int i = 1; i <= n; i++)
    {
        if(!used[i])
        {
            return true;
        }
    }
    return false;
}

int d[1001], p[1001];

void dfs(int v, int pr, int dst = 0)
{
    d[v] = dst;
    for(auto u : g[v])
    {
        if(u != pr)
        {
            p[u] = v;
            dfs(u, v, dst + 1);
        }
    }
}

int farest(int v)
{
    dfs(v, -1);
    int max1 = -1, u;
    for(int i = 1; i <= n; i++)
    {
        if(d[i] > max1 && !used[i])
        {
            u = i;
            max1 = d[i];
        }
    }
    return u;
}

int less_common(int v, int u)
{
    int h1 = d[v], h2 = d[u];
    while(h1 != h2)
    {
        if(h1 < h2)
        {
            u = p[u];
            h2--;
        }
        else
        {
            v = p[v];
            h1--;
        }
    }
    //cout << u << v;
    while(u != v)
    {
        u = p[u];
        v = p[v];
    }
    return u;
}

vector <int> get_path(int a, int b)
{
    int lca = less_common(a, b);
    vector <int> path;
    while(a != lca)
    {
        path.push_back(a);
        a = p[a];
    }
    while(b != lca)
    {
        path.push_back(b);
        b = p[b];
    }
    path.push_back(lca);
    return path;
}

void clear_path(int a, int b)
{
    vector <int> path = get_path(a, b);
    for(int i = 0; i < path.size(); i++)
    {
        //cout << path[i] << " ";
        used[path[i]] = true;
    }
    //cout << endl;
}

int solve()
{
    int far = farest(1);
    int lca = farest(far);
    used[lca] = true;
    used[far] = true;
    clear_path(far, lca);
    lca = query(lca, far);
    while(check())
    {
        int a = lca, b;
        b = farest(a);
        used[b] = true;
        clear_path(a, b);
        lca = query(a, b);
    }
    return lca;
}

int query(int a, int b)
{
    cout << "? " << a << " " << b << endl;
    int lca;
    cin >> lca;
    return lca;
}

int main()
{
    //int n;
    cin >> n;
    fill(used, used + n + 1, false);
    for(int i = 0; i < n - 1; i++)
    {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    cout << "! " << solve();
    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 1e3+5;
const ll mod = 1e9+7;

ll lca;
vector <ll> adj[SIZE];
ll deg[SIZE];

//void destroy(ll u, ll p) {
//    if(u == lca) return;
//
//    ll i, v;
//    vector <ll> ver;
//
//    fori(it, adj[u]) {
//        v = *it;
//        ver.pb(v);
//        if(v == p) continue;
//
//        destroy(v, u);
//    }
//
//    for0(i, ver.size()) {
//        adj[u].erase(ver[i]);
//    }
//}

vector <ll> pp;
bool done[SIZE];
bool path(ll u, ll p) {
    if(u == lca) return 1;

    ll i, v;
    bool ok = 0;

    for0(i, adj[u].size()) {
        v = adj[u][i];
        if(v == p) continue;

        bool f = path(v, u);
        if(f == 1) ok = 1;
    }
    if(ok) pp.pb(u);

    return ok;
}

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n;
    for1(i, n-1) {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
        deg[x]++;
        deg[y]++;
    }

    c = n/2;

    for1(i, n) {
        if(deg[i] == 1) {
            p = i;
            done[i] = 1;
            break;
        }
    }

    while(c--) {
        g = INF;
        for1(i, n) {
            if(!done[i] && g > deg[i]) {
                y = i;
                g = deg[i];
//                break;
            }
        }
//        for1(i, n) {
//            cout << i << " " << adj[i].size() << endl;
//        }
//        cout << endl;

        cout << "? " << p << " " << y << endl;
        cin >> lca;

        if(lca == p || lca == y) {
            cout << "! " << lca << endl;
            return 0;
        }

        path(p, -1);
        path(y, -1);

        for0(i, pp.size()) {
            done[pp[i]] = 1;
            deg[pp[i]] -= 2;
        }
        done[lca] = 1;
        deg[lca] -= 2;
        deg[p]++;
        deg[y]++;

        p = lca;
    }

    cout << "! " << lca << endl;

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 1e3+5;
const ll mod = 1e9+7;

ll lca;
set <ll> adj[SIZE];

void destroy(ll u, ll p) {
    if(u == lca) return;

    ll i, v;
    vector <ll> ver;

    fori(it, adj[u]) {
        v = *it;
        ver.pb(v);
        if(v == p) continue;

        destroy(v, u);
    }

    for0(i, ver.size()) {
        adj[u].erase(ver[i]);
    }
}

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n;
    for1(i, n-1) {
        cin >> x >> y;
        adj[x].insert(y);
        adj[y].insert(x);
    }

    c = n/2;

    for1(i, n) {
        ll sz = adj[i].size();
        if(sz == 1) {
            p = i;
            break;
        }
    }

    while(c--) {
        for1(i, n) {
            x = adj[i].size();
            if(x == 1 && i != p) {
                y = i;
                break;
            }
        }
//        for1(i, n) {
//            cout << i << " " << adj[i].size() << endl;
//        }
//        cout << endl;

        cout << "? " << p << " " << y << endl;
        cin >> lca;

        if(lca == p || lca == y) {
            cout << "! " << lca << endl;
            return 0;
        }

        destroy(p, -1);
        destroy(y, -1);
        p = lca;
    }

    cout << "! " << lca << endl;

//    for1(i, n) {
//        x = adj[i].size();
//        if(x == 1) {
//            cout << "! " << i << endl;
//            return 0;
//        }
//    }

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 1e3+5;
const ll mod = 1e9+7;

ll lca;
vector <ll> adj[SIZE];
ll deg[SIZE];

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n;
    for1(i, n-1) {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
        deg[x]++;
        deg[y]++;
    }

    c = n/2;

    while(c--) {
        vector <ll> v;
        for1(i, n) {
            if(deg[i] == 1) {
                v.pb(i);
                if(v.size() == 2) break;
            }
        }

        cout << "? " << v[0] << " " << v[1] << endl;
        cin >> lca;

        if(lca == v[0] || lca == v[1]) {
            cout << "! " << lca << endl;
            return 0;
        }

        for0(i, adj[v[0]].size()) {
            x = adj[v[0]][i];
            deg[x]--;
        }
        for0(i, adj[v[1]].size()) {
            x = adj[v[1]][i];
            deg[x]--;
        }
    }

    for1(i, n) {
        if(deg[i] == 1) {
            cout << "! " << i << endl;
            return 0;
        }
    }

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 1e3+5;
const ll mod = 1e9+7;

ll lca;
vector <ll> adj[SIZE];
ll deg[SIZE];

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n;
    for1(i, n-1) {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
        deg[x]++;
        deg[y]++;
    }

    c = n/2;

    while(c--) {
        vector <ll> v;
        for1(i, n) {
            if(deg[i] == 1) {
                v.pb(i);
                if(v.size() == 2) break;
            }
        }

        cout << "? " << v[0] << " " << v[1] << endl;
        cin >> lca;

        if(lca == v[0] || lca == v[1]) {
            cout << "! " << lca << endl;
            return 0;
        }

        deg[v[0]]--;
        deg[v[1]]--;
        for0(i, adj[v[0]].size()) {
            x = adj[v[0]][i];
            deg[x]--;
        }
        for0(i, adj[v[1]].size()) {
            x = adj[v[1]][i];
            deg[x]--;
        }
    }

    cout << "! " << lca << endl;

//    for1(i, n) {
//        if(deg[i] == 1) {
//            cout << "! " << i << endl;
//            return 0;
//        }
//    }

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 1e3+5;
const ll mod = 1e9+7;

ll lca;
vector <ll> adj[SIZE];

void destroy(ll u, ll p) {
    if(u == lca) return;

    ll i, v;

    for0(i, adj[u].size()) {
        v = adj[u][i];
        if(v == p) continue;

        destroy(v, u);
    }

    while(1) {
        ll sz = adj[u].size();
        if(sz == 0) break;

        adj[u].erase(adj[u].begin());
    }
}

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n;
    for1(i, n-1) {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    c = n/2;

    while(c--) {
        vector <ll> v;
        for1(i, n) {
            x = adj[i].size();
            if(x == 1) {
                v.pb(i);
                if(v.size() == 2) break;
            }
        }

        cout << "? " << v[0] << " " << v[1] << endl;
        cin >> lca;

        if(lca == v[0] || lca == v[1]) {
            cout << "! " << lca << endl;
            return 0;
        }

        destroy(v[0], -1);
        destroy(v[1], -1);
    }

    for1(i, n) {
        x = adj[i].size();
        if(x == 1) {
            cout << "! " << i << endl;
            return 0;
        }
    }

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 1e3+5;
const ll mod = 1e9+7;

ll lca;
vector <ll> adj[SIZE];

//void destroy(ll u, ll p) {
//    if(u == lca) return;
//
//    ll i, v;
//    vector <ll> ver;
//
//    fori(it, adj[u]) {
//        v = *it;
//        ver.pb(v);
//        if(v == p) continue;
//
//        destroy(v, u);
//    }
//
//    for0(i, ver.size()) {
//        adj[u].erase(ver[i]);
//    }
//}

vector <ll> pp;
bool done[SIZE];
bool path(ll u, ll p) {
    if(u == lca) return 1;

    ll i, v;
    bool ok = 0;

    for0(i, adj[u].size()) {
        v = adj[u][i];
        if(v == p) continue;

        bool f = path(v, u);
        if(f == 1) ok = 1;
    }
    if(ok) pp.pb(u);

    return ok;
}

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n;
    for1(i, n-1) {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    c = n/2;

    for1(i, n) {
        ll sz = adj[i].size();
        if(sz == 1) {
            p = i;
            done[i] = 1;
            break;
        }
    }

    while(c--) {
        for1(i, n) {
            if(!done[i]) {
                y = i;
                break;
            }
        }
//        for1(i, n) {
//            cout << i << " " << adj[i].size() << endl;
//        }
//        cout << endl;

        cout << "? " << p << " " << y << endl;
        cin >> lca;

        if(lca == p || lca == y) {
            cout << "! " << lca << endl;
            return 0;
        }

        path(p, -1);
        path(y, -1);

        for0(i, pp.size()) {
            done[pp[i]] = 1;
        }
        done[lca] = 1;

        p = lca;
    }

    cout << "! " << lca << endl;

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 1e3+5;
const ll mod = 1e9+7;

ll lca;
vector <ll> adj[SIZE];
ll deg[SIZE];

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n;
    for1(i, n-1) {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
        deg[x]++;
        deg[y]++;
    }

    c = n/2;

    while(c--) {
        vector <ll> v;
        for1(i, n) {
            if(deg[i] == 1) {
                v.pb(i);
                if(v.size() == 2) break;
            }
        }

        cout << "? " << v[0] << " " << v[1] << endl;
        cin >> lca;

        if(lca == v[0] || lca == v[1]) {
            cout << "! " << lca << endl;
            return 0;
        }

        deg[v[0]]--;
        deg[v[1]]--;
        for0(i, adj[v[0]].size()) {
            x = adj[v[0]][i];
            deg[x]--;
        }
        for0(i, adj[v[1]].size()) {
            x = adj[v[1]][i];
            deg[x]--;
        }
    }

    for1(i, n) {
        if(deg[i] == 1) {
            cout << "! " << i << endl;
            return 0;
        }
    }

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 1e3+5;
const ll mod = 1e9+7;

ll lca;
vector <ll> adj[SIZE];
ll deg[SIZE];

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n;
    for1(i, n-1) {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
        deg[x]++;
        deg[y]++;
    }

    c = n/2;

    while(c--) {
        vector <ll> v;
        for1(i, n) {
            if(deg[i] == 1) {
                v.pb(i);
                if(v.size() == 2) break;
            }
        }

        cout << "? " << v[0] << " " << v[1] << endl;
        cin >> lca;

        if(lca == v[0] || lca == v[1]) {
            cout << "! " << lca << endl;
            return 0;
        }

        deg[v[0]]--;
        deg[v[1]]--;
        for0(i, adj[v[0]].size()) {
            x = adj[v[0]][i];
            deg[x]--;
        }
        for0(i, adj[v[1]].size()) {
            x = adj[v[1]][i];
            deg[x]--;
        }
    }

    cout << "! " << lca << endl;

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 1e3+5;
const ll mod = 1e9+7;

ll lca;
set <ll> adj[SIZE];

void destroy(ll u, ll p) {
    if(u == lca) return;

    ll i, v;
    vector <ll> ver;

    fori(it, adj[u]) {
        v = *it;
        if(v == p) continue;

        destroy(v, u);
        ver.pb(v);
    }

    for0(i, ver.size()) {
        adj[u].erase(ver[i]);
    }
}

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n;
    for1(i, n-1) {
        cin >> x >> y;
        adj[x].insert(y);
        adj[y].insert(x);
    }

    c = n/2;

    while(c--) {
        vector <ll> v;
        for1(i, n) {
            x = adj[i].size();
            if(x == 1) {
                v.pb(i);
                if(v.size() == 2) break;
            }
        }

        cout << "? " << v[0] << " " << v[1] << endl;
        cin >> lca;

        if(lca == v[0] || lca == v[1]) {
            cout << "! " << lca << endl;
            return 0;
        }

        destroy(v[0], -1);
        destroy(v[1], -1);
    }

    for1(i, n) {
        x = adj[i].size();
        if(x == 1) {
            cout << "! " << i << endl;
            return 0;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

set<int> neig[1010];

set<int> on;
void mremove(int u , int par){

	if(on.find(u) != on.end())
		on.erase(u);

	if(neig[par].find(u) != neig[par].end())
		neig[par].erase(u);

	if(neig[u].find(par) != neig[u].end())
		neig[u].erase(par);

	for(auto x : neig[u]){
		if(x != par)
			mremove(x , u);
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

  	int n;
  	scanf("%d", &n);
  	// cin >> n;

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		// cin >> u >> v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		neig[u].insert(v);
  		neig[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		on.insert(i);
  	}

  	auto ask = [&](int u , int v , int w) {
  		// cerr << u << " " << v << " " << w << endl;
  		printf("? %d %d\n", u + 1 , v + 1);
  		printf("\n");
  		fflush(stdout);
  		// cout <<"? " <<  u + 1 << " " << v + 1 << endl;
  		// cout << fflush;
  		int ans;
  		scanf("%d", &ans);
  		// cin >> ans;
  		ans--;
  		if(ans == u){
  			mremove(w , u);
  		}
  		if(ans == w){
  			mremove(v , w);
  			mremove(u , w);
  		}
  		if(ans == v){
  			mremove(w , v);
  		}
  		return ans;
  	};

  	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		// cout << "! " << x + 1 << endl;
  		// cout << fflush;
  	};

  	while(on.size() > 2){
  		for(int i = 0; i < n; i++){
  			if(neig[i].size() > 1){
  				auto it = neig[i].begin();
  				int u = *it;
  				it++;
  				int v = *it;
  				ask(u , v , i);
  				break;
  			}
  		}
  	}

  	if(on.size() == 1){
  		answer(*on.begin());
  	}else{
  		auto it = on.begin();
		int u = *it;
		it++;
		int v = *it;
		int ans = ask(u , v , v);
		answer(ans);
  	}

}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

set<int> neig[1010];

set<int> on;
void mremove(int u , int par){

	if(on.find(u) != on.end())
		on.erase(u);

	if(neig[par].find(u) != neig[par].end())
		neig[par].erase(u);

	if(neig[u].find(par) != neig[u].end())
		neig[u].erase(par);

	for(auto x : neig[u]){
		if(x != par)
			mremove(x , u);
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

  	int n;
  	scanf("%d", &n);
  	// cin >> n;

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		cin >> u >> v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		neig[u].insert(v);
  		neig[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		on.insert(i);
  	}

  	auto ask = [&](int u , int v , int w) {
  		// cerr << u << " " << v << " " << w << endl;
  		printf("? %d %d\n", u + 1 , v + 1);
  		fflush(stdout);
  		// cout <<"? " <<  u + 1 << " " << v + 1 << endl;
  		// cout << fflush;
  		int ans;
  		scanf("%d", &ans);
  		// cin >> ans;
  		ans--;
  		if(ans == u){
  			mremove(w , u);
  		}
  		if(ans == w){
  			mremove(v , w);
  			mremove(u , w);
  		}
  		if(ans == v){
  			mremove(w , v);
  		}
  		return ans;
  	};

  	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		// cout << "! " << x + 1 << endl;
  		// cout << fflush;
  	};

  	while(on.size() > 2){
  		for(int i = 0; i < n; i++){
  			if(neig[i].size() > 1){
  				auto it = neig[i].begin();
  				int u = *it;
  				it++;
  				int v = *it;
  				ask(u , v , i);
  				break;
  			}
  		}
  	}

  	if(on.size() == 1){
  		answer(*on.begin());
  	}else{
  		auto it = on.begin();
		int u = *it;
		it++;
		int v = *it;
		int ans = ask(u , v , v);
		answer(ans);
  	}

}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

set<int> neig[10100];
set<int> on;

void mremove(int u , int par){

	if(on.find(u) != on.end()){
		on.erase(u);
		cerr << "Erased " << u + 1 << endl;
	}

	if(neig[par].find(u) != neig[par].end())
		neig[par].erase(u);

	if(neig[u].find(par) != neig[u].end())
		neig[u].erase(par);

	for(auto x : neig[u]){
		if(x != par)
			mremove(x , u);
	}
}
int main()
{

  	int n;
  	scanf("%d", &n);

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		neig[u].insert(v);
  		neig[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		on.insert(i);
  	}

	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		exit(0);
  	};

  	auto ask = [&](int u , int v , int w) {

  		printf("? %d %d\n", u + 1 , v + 1);
  		fflush(stdout);

  		int ans;
  		scanf("%d", &ans);
  		ans--;

  		if(ans == u){
  			mremove(w , u);
  		}else
  		if(ans == w){
  			mremove(v , w);
  			mremove(u , w);
  		}else
  		if(ans == v){
  			mremove(w , v);
  		}
  		return ans;
  	};

  	while(on.size() > 2){
  		for(int i = 0; i < n; i++){
  			if(neig[i].size() > 1){
  				auto it = neig[i].begin();
  				int u = *it;
  				it++;
  				int v = *it;
  				ask(u , v , i);
  				break;
  			}
  		}
  	}

  	if(on.size() == 1){
  		answer(*on.begin());
  	}else{
  		auto it = on.begin();
		int u = *it;
		it++;
		int v = *it;
		int ans = ask(u , v , v);
		answer(ans);
  	}

}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

set<int> neig[1010];

set<int> on;
void mremove(int u , int par){

	if(on.find(u) != on.end())
		on.erase(u);

	if(neig[par].find(u) != neig[par].end())
		neig[par].erase(u);

	if(neig[u].find(par) != neig[u].end())
		neig[u].erase(par);

	for(auto x : neig[u]){
		if(x != par)
			mremove(x , u);
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

  	int n;
  	scanf("%d", &n);
  	// cin >> n;

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		cin >> u >> v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		neig[u].insert(v);
  		neig[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		on.insert(i);
  	}

  	auto ask = [&](int u , int v , int w) {
  		// cerr << u << " " << v << " " << w << endl;
  		printf("? %d %d\n", u + 1 , v + 1);
  		printf("\n")
  		fflush(stdout);
  		// cout <<"? " <<  u + 1 << " " << v + 1 << endl;
  		// cout << fflush;
  		int ans;
  		scanf("%d", &ans);
  		// cin >> ans;
  		ans--;
  		if(ans == u){
  			mremove(w , u);
  		}
  		if(ans == w){
  			mremove(v , w);
  			mremove(u , w);
  		}
  		if(ans == v){
  			mremove(w , v);
  		}
  		return ans;
  	};

  	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		// cout << "! " << x + 1 << endl;
  		// cout << fflush;
  	};

  	while(on.size() > 2){
  		for(int i = 0; i < n; i++){
  			if(neig[i].size() > 1){
  				auto it = neig[i].begin();
  				int u = *it;
  				it++;
  				int v = *it;
  				ask(u , v , i);
  				break;
  			}
  		}
  	}

  	if(on.size() == 1){
  		answer(*on.begin());
  	}else{
  		auto it = on.begin();
		int u = *it;
		it++;
		int v = *it;
		int ans = ask(u , v , v);
		answer(ans);
  	}

}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

int main()
{

  	int n;
  	scanf("%d", &n);
  	vector<set<int>> g(n);
  	set<int> leaves;

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		g[u].insert(v);
  		g[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		if(g[i].size() == 1){
  			leaves.insert(i);
  		}
  	}

	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		exit(0);
  	};

  	auto ask = [&](int u , int v) {

  		printf("? %d %d\n", u + 1 , v + 1);
  		fflush(stdout);

  		int ans;
  		scanf("%d", &ans);
  		ans--;
  		return ans;
  	};

  	while(leaves.size() >= 2){
		auto it = leaves.begin();
		int u = *it;
		it++;
		int v = *it;

		int lca = ask(u , v);
		if(lca == u){
			answer(u);
		}else
		if(lca == v){
			answer(v);
		}else{
			leaves.erase(u);
			int foo = *g[u].begin();
			g[foo].erase(u);
			if(g[foo].size() == 1)
				leaves.insert(foo);

			leaves.erase(v);
			foo = *g[v].begin();
			g[foo].erase(u);
			if(g[foo].size() == 1)
				leaves.insert(foo);

		}
  	}

	answer(*leaves.begin());
}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

set<int> neig[10100];
set<int> on;

void mremove(int u , int par){

	if(on.find(u) != on.end())
		on.erase(u);

	if(neig[par].find(u) != neig[par].end())
		neig[par].erase(u);

	if(neig[u].find(par) != neig[u].end())
		neig[u].erase(par);

	for(auto x : neig[u]){
		if(x != par)
			mremove(x , u);
	}
}
int main()
{

  	int n;
  	scanf("%d", &n);

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		neig[u].insert(v);
  		neig[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		on.insert(i);
  	}

  	auto ask = [&](int u , int v , int w) {

  		printf("? %d %d\n", u + 1 , v + 1);
  		printf("\n");
  		fflush(stdout);

  		int ans;
  		scanf("%d", &ans);

  		ans--;
  		assert(ans == u || ans == v || ans == w);
  		if(ans == u){
  			mremove(w , u);
  		}else
  		if(ans == w){
  			mremove(v , w);
  			mremove(u , w);
  		}else
  		if(ans == v){
  			mremove(w , v);
  		}
  		return ans;
  	};

  	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		exit(0);
  	};

  	while(on.size() > 2){
  		for(int i = 0; i < n; i++){
  			if(neig[i].size() > 1){
  				auto it = neig[i].begin();
  				int u = *it;
  				it++;
  				int v = *it;
  				ask(u , v , i);
  				break;
  			}
  		}
  	}

  	if(on.size() == 1){
  		answer(*on.begin());
  	}else{
  		auto it = on.begin();
		int u = *it;
		it++;
		int v = *it;
		int ans = ask(u , v , v);
		answer(ans);
  	}

}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

set<int> neig[10100];
set<int> on;

void mremove(int u , int par){

	if(on.find(u) != on.end())
		on.erase(u);

	if(neig[par].find(u) != neig[par].end())
		neig[par].erase(u);

	if(neig[u].find(par) != neig[u].end())
		neig[u].erase(par);

	for(auto x : neig[u]){
		if(x != par)
			mremove(x , u);
	}
}
int main()
{

  	int n;
  	scanf("%d", &n);

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		neig[u].insert(v);
  		neig[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		on.insert(i);
  	}

	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		exit(0);
  	};

  	auto ask = [&](int u , int v , int w) {

  		printf("? %d %d\n", u + 1 , v + 1);
  		printf("\n");
  		fflush(stdout);

  		int ans;
  		scanf("%d", &ans);

  		ans--;
  		if(!(ans == u || ans == v || ans == w)){
			answer(1);
  		}

  		if(ans == u){
  			mremove(w , u);
  		}else
  		if(ans == w){
  			mremove(v , w);
  			mremove(u , w);
  		}else
  		if(ans == v){
  			mremove(w , v);
  		}
  		return ans;
  	};

  	while(on.size() > 2){
  		for(int i = 0; i < n; i++){
  			if(neig[i].size() > 1){
  				auto it = neig[i].begin();
  				int u = *it;
  				it++;
  				int v = *it;
  				ask(u , v , i);
  				break;
  			}
  		}
  	}

  	if(on.size() == 1){
  		answer(*on.begin());
  	}else{
  		auto it = on.begin();
		int u = *it;
		it++;
		int v = *it;
		int ans = ask(u , v , v);
		answer(ans);
  	}

}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

set<int> neig[1010];

set<int> on;
void mremove(int u , int par){

	if(on.find(u) != on.end())
		on.erase(u);

	if(neig[par].find(u) != neig[par].end())
		neig[par].erase(u);

	if(neig[u].find(par) != neig[u].end())
		neig[u].erase(par);

	for(auto x : neig[u]){
		if(x != par)
			mremove(x , u);
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

  	int n;
  	scanf("%d", &n);
  	// cin >> n;

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		cin >> u >> v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		neig[u].insert(v);
  		neig[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		on.insert(i);
  	}

  	auto ask = [&](int u , int v , int w) {
  		// cerr << u << " " << v << " " << w << endl;
  		printf("? %d %d\n", u + 1 , v + 1);
  		printf("\n");
  		fflush(stdout);
  		// cout <<"? " <<  u + 1 << " " << v + 1 << endl;
  		// cout << fflush;
  		int ans;
  		scanf("%d", &ans);
  		// cin >> ans;
  		ans--;
  		if(ans == u){
  			mremove(w , u);
  		}
  		if(ans == w){
  			mremove(v , w);
  			mremove(u , w);
  		}
  		if(ans == v){
  			mremove(w , v);
  		}
  		return ans;
  	};

  	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		// cout << "! " << x + 1 << endl;
  		// cout << fflush;
  	};

  	while(on.size() > 2){
  		for(int i = 0; i < n; i++){
  			if(neig[i].size() > 1){
  				auto it = neig[i].begin();
  				int u = *it;
  				it++;
  				int v = *it;
  				ask(u , v , i);
  				break;
  			}
  		}
  	}

  	if(on.size() == 1){
  		answer(*on.begin());
  	}else{
  		auto it = on.begin();
		int u = *it;
		it++;
		int v = *it;
		int ans = ask(u , v , v);
		answer(ans);
  	}

}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

set<int> neig[10100];
set<int> on;

void mremove(int u , int par){

	if(on.find(u) != on.end()){
		on.erase(u);
		cerr << "Erased " << u + 1 << endl;
	}

	if(neig[par].find(u) != neig[par].end())
		neig[par].erase(u);

	if(neig[u].find(par) != neig[u].end())
		neig[u].erase(par);

	for(auto x : neig[u]){
		if(x != par)
			mremove(x , u);
	}
}
int main()
{

  	int n;
  	scanf("%d", &n);

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		neig[u].insert(v);
  		neig[v].insert(u);
  	}
  	fflush(stdout);
  	for(int i = 0; i < n; i++){
  		on.insert(i);
  	}

	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		fflush(stdout);
  		exit(0);
  	};

  	auto ask = [&](int u , int v , int w) {

  		printf("? %d %d\n", u + 1 , v + 1);
  		fflush(stdout);
  		fflush(stdout);

  		int ans;
  		scanf("%d", &ans);
  		ans--;

  		if(ans == u){
  			mremove(w , u);
  		}else
  		if(ans == w){
  			mremove(v , w);
  			mremove(u , w);
  		}else
  		if(ans == v){
  			mremove(w , v);
  		}
  		return ans;
  	};

  	while(on.size() > 2){
  		for(int i = 0; i < n; i++){
  			if(neig[i].size() > 1){
  				auto it = neig[i].begin();
  				int u = *it;
  				it++;
  				int v = *it;
  				ask(u , v , i);
  				break;
  			}
  		}
  	}

  	if(on.size() == 1){
  		answer(*on.begin());
  	}else{
  		auto it = on.begin();
		int u = *it;
		it++;
		int v = *it;
		int ans = ask(u , v , v);
		answer(ans);
  	}

}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

set<int> neig[1010];

set<int> on;
void mremove(int u , int par){

	if(on.find(u) != on.end())
		on.erase(u);

	if(neig[par].find(u) != neig[par].end())
		neig[par].erase(u);

	if(neig[u].find(par) != neig[u].end())
		neig[u].erase(par);

	for(auto x : neig[u]){
		if(x != par)
			mremove(x , u);
	}
}
int main()
{

  	int n;
  	scanf("%d", &n);

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		neig[u].insert(v);
  		neig[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		on.insert(i);
  	}

  	auto ask = [&](int u , int v , int w) {

  		printf("? %d %d\n", u + 1 , v + 1);
  		printf("\n");
  		fflush(stdout);

  		int ans;
  		scanf("%d", &ans);

  		ans--;
  		if(ans == u){
  			mremove(w , u);
  		}
  		if(ans == w){
  			mremove(v , w);
  			mremove(u , w);
  		}
  		if(ans == v){
  			mremove(w , v);
  		}
  		return ans;
  	};

  	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		exit(0);
  	};

  	while(on.size() > 2){
  		for(int i = 0; i < n; i++){
  			if(neig[i].size() > 1){
  				auto it = neig[i].begin();
  				int u = *it;
  				it++;
  				int v = *it;
  				ask(u , v , i);
  				break;
  			}
  		}
  	}

  	if(on.size() == 1){
  		answer(*on.begin());
  	}else{
  		auto it = on.begin();
		int u = *it;
		it++;
		int v = *it;
		int ans = ask(u , v , v);
		answer(ans);
  	}

}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

int main()
{

  	int n;
  	scanf("%d", &n);
  	vector<set<int>> g(n);
  	set<int> leaves;

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		g[u].insert(v);
  		g[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		if(g[i].size() == 1){
  			leaves.insert(i);
  		}
  	}

	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		exit(0);
  	};

  	auto ask = [&](int u , int v) {

  		printf("? %d %d\n", u + 1 , v + 1);
  		fflush(stdout);

  		int ans;
  		scanf("%d", &ans);
  		ans--;
  		return ans;
  	};

  	while(leaves.size() >= 2){
		auto it = leaves.begin();
		int u = *it;
		it++;
		int v = *it;

		int lca = ask(u , v);
		if(lca == u){
			answer(u);
		}else
		if(lca == v){
			answer(v);
		}else{
			leaves.erase(u);
			int foo = *g[u].begin();
			g[foo].erase(u);
			if(g[foo].size() == 1)
				leaves.insert(foo);

			leaves.erase(v);
			foo = *g[v].begin();
			g[foo].erase(v);
			if(g[foo].size() == 1)
				leaves.insert(foo);

		}
  	}

	answer(*leaves.begin());
}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

int main()
{

  	int n;
  	scanf("%d", &n);
  	vector<set<int>> g(n);
  	set<int> leaves;

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		g[u].insert(v);
  		g[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		if(g[i].size() == 1){
  			leaves.insert(i);
  		}
  	}

	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		exit(0);
  	};

  	auto ask = [&](int u , int v) {

  		printf("? %d %d\n", u + 1 , v + 1);
  		fflush(stdout);

  		int ans;
  		scanf("%d", &ans);
  		ans--;
  		return ans;
  	};

  	while(leaves.size() >= 2){
		auto it = leaves.begin();
		int u = *it;
		it++;
		int v = *it;

		int lca = ask(u , v);
		if(lca == u){
			answer(u);
		}else
		if(lca == v){
			answer(v);
		}else{
			leaves.erase(u);
			int foo = *g[u].begin();
			leaves.insert(foo);
			g[foo].erase(u);

			leaves.erase(v);
			foo = *g[v].begin();
			leaves.insert(foo);
			g[foo].erase(v);
		}
  	}

	answer(*leaves.begin());
}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

set<int> neig[10100];
set<int> on;

void mremove(int u , int par){

	if(on.find(u) != on.end()){
		on.erase(u);
		cerr << "Erased " << u + 1 << endl;
	}

	if(neig[par].find(u) != neig[par].end())
		neig[par].erase(u);

	if(neig[u].find(par) != neig[u].end())
		neig[u].erase(par);

	for(auto x : neig[u]){
		if(x != par)
			mremove(x , u);
	}
}
int main()
{

  	int n;
  	scanf("%d", &n);

  	for(int i = 0; i < n-1; i++){
  		int u, v;
  		scanf("%d %d", &u, &v);
  		u-- , v--;
  		neig[u].insert(v);
  		neig[v].insert(u);
  	}

  	for(int i = 0; i < n; i++){
  		on.insert(i);
  	}

	auto answer = [&](int x){
  		printf("! %d\n", x + 1);
  		fflush(stdout);
  		exit(0);
  	};

  	auto ask = [&](int u , int v , int w) {

  		printf("? %d %d\n", u + 1 , v + 1);
  		printf("\n");
  		fflush(stdout);

  		int ans;
  		scanf("%d", &ans);
  		ans--;
  		if(on.size() == 2){
  			return ans;
  		}

  		if(ans == u){
  			mremove(w , u);
  		}else
  		if(ans == w){
  			mremove(v , w);
  			mremove(u , w);
  		}else
  		if(ans == v){
  			mremove(w , v);
  		}
  		return ans;
  	};

  	while(on.size() > 2){
  		for(int i = 0; i < n; i++){
  			if(neig[i].size() > 1){
  				auto it = neig[i].begin();
  				int u = *it;
  				it++;
  				int v = *it;
  				ask(u , v , i);
  				break;
  			}
  		}
  	}

  	if(on.size() == 1){
  		answer(*on.begin());
  	}else{
  		auto it = on.begin();
		int u = *it;
		it++;
		int v = *it;
		int ans = ask(u , v , v);
		answer(ans);
  	}

}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
//#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1000000007;
const int N = (int)(5e5) + 10;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, lvl[1111], p[1111];
bool vis[1111], disc[1111];
vector<vector<int> >g;

int bfs(int u)
{
	memset(vis, false, sizeof(vis));
	memset(lvl, false, sizeof(lvl));
	queue<int>q;
	q.push(u);
	vis[u] = 1;
	int mx = 0, id = u;
	while (q.size())
	{
		int fr = q.front();
		q.pop();
		for (int i = 0; i < g[fr].size(); i++)
		{
			int v = g[fr][i];
			if (!vis[v])
			{
				q.push(v);
				vis[v] = 1;
				lvl[v] = 1 + lvl[fr];
				p[v] = u;
				if (lvl[v] > mx && !disc[v])
				{
					mx = lvl[v];
					id = v;
				}
			}
		}
	}

	return id;
}

int ask(int x, int y)
{
	cout << "? " << x << ' ' << y << endl;
	int gt = 0;
	cin >> gt;
	return gt;
}

int main()
{
	//inp();
	cin >> n;
	g.resize(n + 1);
	for (int x, y, i = 1; i < n; i++)
	{
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}

	int cur = bfs(1), nxt = bfs(cur);
	n /= 2;

	while (n--)
	{
		del(cur, nxt, n);
		int gt = ask(cur, nxt);
		if(gt == cur || gt == nxt)return cout << "! " << gt << endl,0;
		cur = bfs(cur);
		nxt = bfs(cur);
		disc[cur] = disc[nxt] = 1;
	}

	cout << "! " << cur << endl;
}

/*10
1 2
2 3
2 5
3 4
5 6
6 7
7 8
8 9
9 10*/


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
//#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1000000007;
const int N = (int)(5e5) + 10;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, lvl[1111], p[1111];
bool vis[1111], disc[1111];
vector<vector<int> >g;

int bfs(int u)
{
	memset(vis, false, sizeof(vis));
	memset(lvl, false, sizeof(lvl));
	queue<int>q;
	q.push(u);
	vis[u] = 1;
	int mx = 0, id = u;
	while (q.size())
	{
		int fr = q.front();
		q.pop();
		for (int i = 0; i < g[fr].size(); i++)
		{
			int v = g[fr][i];
			if (!vis[v] )
			{
				q.push(v);
				vis[v] = 1;
				lvl[v] = 1 + lvl[fr];
				p[v] = u;
				if (lvl[v] > mx && !disc[v])
				{
					mx = lvl[v];
					id = v;
				}
			}
		}
	}

	return id;
}

int ask(int x, int y)
{
	cout << "? " << x << ' ' << y << endl;
	int gt = 0;
	cin >> gt;
	return gt;
}

bool BFS(int src, int dest)
{
	queue<int> q;
	for (int i = 0; i <= n + 10; i++) {
		p[i] = -1;
	}
	lvl[src] = 0;
	memset(vis, false, sizeof(vis));
	vis[src] = true;
	p[src] = 0;
	q.push(src);

	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int i = 0; i < g[u].size(); i++) {
			if (vis[g[u][i]] == false)
			{
				vis[g[u][i]] = true;
				lvl[g[u][i]] = lvl[u] + 1;
				p[g[u][i]] = u;
				q.push(g[u][i]);
				if (g[u][i] == dest)
					return true;
			}
		}
	}

	return false;
}

void del(int s, int dest, int v)
{

	if (BFS(s, dest) == false)
	{
		return;
	}

	vector<int> path;
	int crawl = dest;
	path.push_back(crawl);
	while (p[crawl] != -1) {
		path.push_back(p[crawl]);
		crawl = p[crawl];
	}

	for (int i = path.size() - 1; i >= 0; i--)
		disc[path[i]] = 1;
}

int main()
{
	//inp();
	cin >> n;
	g.resize(n + 1);
	for (int x, y, i = 1; i < n; i++)
	{
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}

	int cur = bfs(1), nxt = bfs(cur);
	n /= 2;

	while (n--)
	{
		del(cur, nxt, n);
		cur = ask(cur, nxt);
		nxt = bfs(cur);
	}

	cout << "! " << cur << endl;
}

/*10
1 2
2 3
2 5
3 4
5 6
6 7
7 8
8 9
9 10*/


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
//#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1000000007;
const int N = (int)(5e5) + 10;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, lvl[1111], p[1111];
bool vis[1111], disc[1111];
vector<vector<int> >g;

int bfs(int u)
{
	memset(vis, false, sizeof(vis));
	memset(lvl, false, sizeof(lvl));
	queue<int>q;
	q.push(u);
	vis[u] = 1;
	int mx = 0, id = u;
	while (q.size())
	{
		int fr = q.front();
		q.pop();
		for (int i = 0; i < g[fr].size(); i++)
		{
			int v = g[fr][i];
			if (!vis[v] && !disc[v])
			{
				q.push(v);
				vis[v] = 1;
				lvl[v] = 1 + lvl[fr];
				p[v] = u;
				if (lvl[v] > mx)
				{
					mx = lvl[v];
					id = v;
				}
			}
		}
	}

	return id;
}

int ask(int x, int y)
{
	cout << "? " << x << ' ' << y << endl;
	int gt = 0;
	cin >> gt;
	return gt;
}

bool BFS(int src, int dest)
{
	queue<int> q;
	for (int i = 0; i <= n + 10; i++) {
		lvl[i] = INT_MAX;
		p[i] = -1;
	}
	memset(vis, false, sizeof(vis));
	vis[src] = true;
	p[src] = 0;
	q.push(src);

	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int i = 0; i < g[u].size(); i++) {
			if (vis[g[u][i]] == false)
			{
				vis[g[u][i]] = true;
				lvl[g[u][i]] = lvl[u] + 1;
				p[g[u][i]] = u;
				q.push(g[u][i]);
				if (g[u][i] == dest)
					return true;
			}
		}
	}

	return false;
}

void del(int s,	int dest, int v)
{

	if (BFS(s, dest) == false)
	{
		return;
	}

	vector<int> path;
	int crawl = dest;
	path.push_back(crawl);
	while (p[crawl] != -1) {
		path.push_back(p[crawl]);
		crawl = p[crawl];
	}

	for (int i = path.size() - 1; i >= 0; i--)
		disc[path[i]] = 1;
}

int main()
{
	//inp();
	cin >> n;
	g.resize(n + 1);
	for (int x, y, i = 1; i < n; i++)
	{
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}

	int cur = bfs(1), nxt = bfs(cur);
	n /= 2;

	while (n--)
	{
		del(cur, nxt, n);
		cur = ask(cur, nxt);
		cur = bfs(cur);
		nxt = bfs(cur);
	}

	cout << "! " << cur << endl;
}

/*10
1 2
2 3
2 5
3 4
5 6
6 7
7 8
8 9
9 10*/


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
//#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1000000007;
const int N = (int)(5e5) + 10;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, lvl[1111], p[1111];
bool vis[1111], disc[1111];
vector<vector<int> >g;

int bfs(int u)
{
	memset(vis, false, sizeof(vis));
	memset(lvl, false, sizeof(lvl));
	queue<int>q;
	q.push(u);
	vis[u] = 1;
	int mx = 0, id = u;
	while (q.size())
	{
		int fr = q.front();
		q.pop();
		for (int i = 0; i < g[fr].size(); i++)
		{
			int v = g[fr][i];
			if (!vis[v] && !disc[v])
			{
				q.push(v);
				vis[v] = 1;
				lvl[v] = 1 + lvl[fr];
				p[v] = u;
				if (lvl[v] > mx && g[v].size() == 1)
				{
					mx = lvl[v];
					id = v;
				}
			}
		}
	}

	return id;
}

int ask(int x, int y)
{
	cout << "? " << x << ' ' << y << endl;
	int gt = 0;
	cin >> gt;
	return gt;
}

bool BFS(int src, int dest)
{
	queue<int> q;
	for (int i = 0; i <= n + 10; i++) {
		lvl[i] = 0;
		p[i] = -1;
	}
	memset(vis, false, sizeof(vis));
	vis[src] = true;
	p[src] = 0;
	q.push(src);

	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int i = 0; i < g[u].size(); i++) {
			if (vis[g[u][i]] == false)
			{
				vis[g[u][i]] = true;
				lvl[g[u][i]] = lvl[u] + 1;
				p[g[u][i]] = u;
				q.push(g[u][i]);
				if (g[u][i] == dest)
					return true;
			}
		}
	}

	return false;
}

void del(int s, int dest, int v)
{

	if (BFS(s, dest) == false)
	{
		return;
	}

	vector<int> path;
	int crawl = dest;
	path.push_back(crawl);
	while (p[crawl] != -1) {
		path.push_back(p[crawl]);
		crawl = p[crawl];
	}

	for (int i = path.size() - 1; i >= 0; i--)
		disc[path[i]] = 1;
}

int main()
{
	//inp();
	cin >> n;
	g.resize(n + 1);
	int cur, nxt;
	for (int x, y, i = 1; i < n; i++)
	{
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}
	for (int i = 1; i <= n; i++)if (g[i].size() == 1)cur = i;
	cur = bfs(cur), nxt = bfs(cur);
	n /= 2;

	while (n--)
	{
		del(cur, nxt, n);
		cur = ask(cur, nxt);
		nxt = bfs(cur);
	}

	cout << "! " << cur << endl;
}

/*10
1 2
2 3
2 5
3 4
5 6
6 7
7 8
8 9
9 10*/


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
//#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1000000007;
const int N = (int)(5e5) + 10;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, lvl[1111], p[1111];
bool vis[1111], disc[1111];
vector<vector<int> >g;

int bfs(int u)
{
	memset(vis, false, sizeof(vis));
	memset(lvl, false, sizeof(lvl));
	queue<int>q;
	q.push(u);
	vis[u] = 1;
	int mx = 0, id = u;
	while (q.size())
	{
		int fr = q.front();
		q.pop();
		for (int i = 0; i < g[fr].size(); i++)
		{
			int v = g[fr][i];
			if (!vis[v] && !disc[v])
			{
				q.push(v);
				vis[v] = 1;
				lvl[v] = 1 + lvl[fr];
				p[v] = u;
				if (lvl[v] > mx && g[v].size() == 1)
				{
					mx = lvl[v];
					id = v;
				}
			}
		}
	}

	return id;
}

int ask(int x, int y)
{
	cout << "? " << x << ' ' << y << endl;
	int gt = 0;
	cin >> gt;
	return gt;
}

bool BFS(int src, int dest)
{
	queue<int> q;
	for (int i = 0; i <= n + 10; i++) {
		lvl[i] = 0;
		p[i] = -1;
	}
	memset(vis, false, sizeof(vis));
	vis[src] = true;
	p[src] = 0;
	q.push(src);

	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int i = 0; i < g[u].size(); i++) {
			if (vis[g[u][i]] == false)
			{
				vis[g[u][i]] = true;
				lvl[g[u][i]] = lvl[u] + 1;
				p[g[u][i]] = u;
				q.push(g[u][i]);
				if (g[u][i] == dest)
					return true;
			}
		}
	}

	return false;
}

void del(int s, int dest, int v)
{

	if (BFS(s, dest) == false)
	{
		return;
	}

	vector<int> path;
	int crawl = dest;
	path.push_back(crawl);
	while (p[crawl] != -1) {
		path.push_back(p[crawl]);
		crawl = p[crawl];
	}

	for (int i = path.size() - 1; i >= 0; i--)
		disc[path[i]] = 1;
}

int main()
{
	//inp();
	cin >> n;
	g.resize(n + 1);
	for (int x, y, i = 1; i < n; i++)
	{
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}

	int cur = bfs(1), nxt = bfs(cur);
	n /= 2;

	while (n--)
	{
		del(cur, nxt, n);
		cur = ask(cur, nxt);
		nxt = bfs(cur);
	}

	cout << "! " << cur << endl;
}

/*10
1 2
2 3
2 5
3 4
5 6
6 7
7 8
8 9
9 10*/


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
//#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1000000007;
const int N = (int)(5e5) + 10;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, lvl[1111], p[1111];
bool vis[1111], disc[1111];
vector<vector<int> >g;

int bfs(int u)
{
	memset(vis, false, sizeof(vis));
	memset(lvl, false, sizeof(lvl));
	queue<int>q;
	q.push(u);
	vis[u] = 1;
	int mx = 0, id = -1;
	while (q.size())
	{
		int fr = q.front();
		q.pop();
		for (int i = 0; i < g[fr].size(); i++)
		{
			int v = g[fr][i];
			if (!vis[v])
			{
				q.push(v);
				vis[v] = 1;
				lvl[v] = 1 + lvl[fr];
				p[v] = u;
				if (lvl[v] > mx && !disc[v])
				{
					mx = lvl[v];
					id = v;
				}
			}
		}
	}

	return id;
}

int ask(int x, int y)
{
	cout << "? " << x << ' ' << y << endl;
	int gt = 0;
	cin >> gt;
	return gt;
}

int main()
{
	//inp();
	cin >> n;
	g.resize(n + 1);
	for (int x, y, i = 1; i < n; i++)
	{
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}

	int cur = bfs(1), nxt = bfs(cur);
	n /= 2;
	int ans = 1;
	while (n--)
	{
	        disc[cur] = disc[nxt] = 1;
		ans = ask(cur, nxt);
		cur = bfs(cur);
		if(cur == -1)break;
		nxt = bfs(cur);
	}

	cout << "! " << ans << endl;
}

/*10
1 2
2 3
2 5
3 4
5 6
6 7
7 8
8 9
9 10*/


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
//#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1000000007;
const int N = (int)(5e5) + 10;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, lvl[1111], p[1111];
bool vis[1111], disc[1111];
vector<vector<int> >g;

int bfs(int u)
{
	memset(vis, false, sizeof(vis));
	memset(lvl, false, sizeof(lvl));
	queue<int>q;
	q.push(u);
	vis[u] = 1;
	int mx = 0, id = 1;
	while (q.size())
	{
		int fr = q.front();
		q.pop();
		for (int i = 0; i < g[fr].size(); i++)
		{
			int v = g[fr][i];
			if (!vis[v])
			{
				q.push(v);
				vis[v] = 1;
				lvl[v] = 1 + lvl[fr];
				p[v] = u;
				if (lvl[v] > mx && !disc[v])
				{
					mx = lvl[v];
					id = v;
				}
			}
		}
	}

	return id;
}

int ask(int x, int y)
{
	cout << "? " << x << ' ' << y << endl;
	int gt = 0;
	cin >> gt;
	return gt;
}

int main()
{
	//inp();
	cin >> n;
	g.resize(n + 1);
	for (int x, y, i = 1; i < n; i++)
	{
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}

	int cur = bfs(1), nxt = bfs(cur);
	n /= 2;

	while (n--)
	{
	        disc[cur] = disc[nxt] = 1;
		int gt = ask(cur, nxt);
		cur = bfs(cur);
		nxt = bfs(cur);
	}

	cout << "! " << cur << endl;
}

/*10
1 2
2 3
2 5
3 4
5 6
6 7
7 8
8 9
9 10*/


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
//#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1000000007;
const int N = (int)(5e5) + 10;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, lvl[1111], p[1111];
bool vis[1111], disc[1111];
vector<vector<int> >g;

int bfs(int u)
{
	memset(vis, false, sizeof(vis));
	memset(lvl, false, sizeof(lvl));
	queue<int>q;
	q.push(u);
	vis[u] = 1;
	int mx = 0, id = u;
	while (q.size())
	{
		int fr = q.front();
		q.pop();
		for (int i = 0; i < g[fr].size(); i++)
		{
			int v = g[fr][i];
			if (!vis[v])
			{
				q.push(v);
				vis[v] = 1;
				lvl[v] = 1 + lvl[fr];
				p[v] = u;
				if (lvl[v] > mx && g[v].size() == 1 && !disc[v])
				{
					mx = lvl[v];
					id = v;
				}
			}
		}
	}

	return id;
}

int ask(int x, int y)
{
	cout << "? " << x << ' ' << y << endl;
	int gt = 0;
	cin >> gt;
	return gt;
}

bool BFS(int src, int dest)
{
	queue<int> q;
	for (int i = 0; i <= n + 10; i++) {
		lvl[i] = 0;
		p[i] = -1;
	}
	memset(vis, false, sizeof(vis));
	vis[src] = true;
	p[src] = 0;
	q.push(src);

	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int i = 0; i < g[u].size(); i++) {
			if (vis[g[u][i]] == false)
			{
				vis[g[u][i]] = true;
				lvl[g[u][i]] = lvl[u] + 1;
				p[g[u][i]] = u;
				q.push(g[u][i]);
				if (g[u][i] == dest)
					return true;
			}
		}
	}

	return false;
}

void del(int s, int dest, int v)
{

	if (BFS(s, dest) == false)
	{
		return;
	}

	vector<int> path;
	int crawl = dest;
	path.push_back(crawl);
	while (p[crawl] != -1) {
		path.push_back(p[crawl]);
		crawl = p[crawl];
	}

	for (int i = path.size() - 1; i >= 0; i--)
		disc[path[i]] = 1;
}

int main()
{
	//inp();
	cin >> n;
	g.resize(n + 1);
	int cur, nxt;
	for (int x, y, i = 1; i < n; i++)
	{
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}
	for (int i = 1; i <= n; i++)if (g[i].size() == 1)cur = i;
	cur = bfs(cur), nxt = bfs(cur);
	n /= 2;

	while (n--)
	{
		del(cur, nxt, n);
		cur = ask(cur, nxt);
		nxt = bfs(cur);
	}

	cout << "! " << cur << endl;
}

/*10
1 2
2 3
2 5
3 4
5 6
6 7
7 8
8 9
9 10*/