Ayush and Ashish play a game on an unrooted tree consisting of nn nodes numbered 11 to nn. Players make the following move in turns:
- Select any leaf node in the tree and remove it together with any edge which has this node as one of its endpoints. A leaf node is a node with degree less than or equal to 11.
A tree is a connected undirected graph without cycles.
There is a special node numbered xx. The player who removes this node wins the game.
Ayush moves first. Determine the winner of the game if each player plays optimally.
The first line of the input contains a single integer tt (1≤t≤10)(1≤t≤10) — the number of testcases. The description of the test cases follows.
The first line of each testcase contains two integers nn and xx (1≤n≤1000,1≤x≤n)(1≤n≤1000,1≤x≤n) — the number of nodes in the tree and the special node respectively.
Each of the next n−1n−1 lines contain two integers uu, vv (1≤u,v≤n, u≠v)(1≤u,v≤n, u≠v), meaning that there is an edge between nodes uu and vv in the tree.
For every test case, if Ayush wins the game, print "Ayush", otherwise print "Ashish" (without quotes).
1 3 1 2 1 3 1
Ashish
1 3 2 1 2 1 3
Ayush
For the 11st test case, Ayush can only remove node 22 or 33, after which node 11 becomes a leaf node and Ashish can remove it in his turn.
For the 22nd test case, Ayush can remove node 22 in the first move itself.
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <queue> #include <map> #include <sstream> #include <cstdio> #include <cstring> #include <numeric> #include <cmath> #include <iomanip> #include <deque> #include <bitset> #define ll long long #define PII pair<int, int> #define rep(i,a,b) for(int i=a;i<=b;i++) #define dec(i,a,b) for(int i=a;i>=b;i--) using namespace std; int dir[4][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } }; const long long INF = 0x7f7f7f7f7f7f7f7f; const int inf = 0x3f3f3f3f; const double pi = 3.14159265358979323846; const double eps = 1e-6; const int mod = 998244353; const int N = 2500 + 5; //if(x<0 || x>=r || y<0 || y>=c) inline ll read() { ll x = 0; bool f = true; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); } while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); return f ? x : -x; } ll gcd(ll m, ll n) { return n == 0 ? m : gcd(n, m % n); } ll lcm(ll m, ll n) { return m * n / gcd(m, n); } int main() { int T; cin >> T; while(T--) { int n, x,c=0; cin >> n >> x; vector<vector<int>> a(n + 1); rep(i, 1, n - 1) { int u, v; cin >> u >> v; if (u == x || v == x) c++; } if(c<=1) cout << "Ayush" << endl; else { if (n % 2) cout << "Ashish" << endl; else cout << "Ayush"<< endl; } } return 0; }