/*إِنَّ اللَّهَ وَمَلَائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ ۚ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا*/
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define W int g; cin >> g; while (g--)
#define sz(v) int(v.size())
#define FIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
typedef long long ll;
const long long N = 3e6 + 7, Mod = 1e9 + 7, INF = 2e18;
ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll inv(ll a, ll b = Mod) { return 1 < a ? b - inv(b % a, a) * b / a : 1; }
const int dx[9] = { 0, 0, 1, -1, 1, 1, -1, -1, 0 };
const int dy[9] = { 1, -1, 0, 0, -1, 1, 1, -1, 0 };
bool check(string s){
int i = 0 , j = sz(s) - 1 ;
while (i<j){
if(s[i++]==s[j--])
continue;
return false;
}
return true;
}
void solve() {
int n,ok=0;
cin>>n;
map<string,bool>mp,mp2,mp3;
vector<string>v(n);
string s;
for(int i=0;i<n;i++)
cin>>v[i];
for(int i=0;i<n;i++){
if(sz(v[i])==1 || check(v[i])){
ok = 1;
break;
}
s = v[i];
std::reverse(s.begin(), s.end());
if(sz(v[i])==2){
if(mp2[s] || mp[s])
ok= 1;
mp2[v[i]] = 1;
}
if(sz(v[i])==3){
if(mp3[s])
ok = 1;
s.pop_back();
if(mp2[s])
ok = 1;
mp3[v[i]]=1;
mp[v[i].substr(0,2)] = 1;
}
if(ok)
break;
}
if(ok)
cout<<"YES\n";
else
cout<<"NO\n";
}
int main() {
IO;
W
solve();
}
505B - Mr Kitayuta's Colorful Graph | 1324D - Pair of Topics |
157B - Trace | 34C - Page Numbers |
279A - Point on Spiral | 1294D - MEX maximizing |
447A - DZY Loves Hash | 23B - Party |
63D - Dividing Island | 1203E - Boxers |
1547F - Array Stabilization (GCD version) | 358A - Dima and Continuous Line |
1385C - Make It Good | 651A - Joysticks |
1474D - Cleaning | 1588A - Two Arrays |
816A - Karen and Morning | 9D - How many trees |
918B - Radio Station | 15A - Cottage Village |
1737B - Ela's Fitness and the Luxury Number | 1425H - Huge Boxes of Animal Toys |
1737A - Ela Sorting Books | 768C - Jon Snow and his Favourite Number |
1006C - Three Parts of the Array | 81A - Plug-in |
276C - Little Girl and Maximum Sum | 1738D - Permutation Addicts |
1348B - Phoenix and Beauty | 186A - Comparing Strings |