#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; bool rcmp(int a, int b) { return a>b; } typedef long long LL; class mypcmp { public: bool operator()(const int& a, const int& b) { return a cs; for (i=0; i=n) { printf("Yes\n"); return 0; } if (k>n) { printf("No\n"); return 0; } for (i=0; i=n) { printf("Yes\n"); return 0; } if (k==n) { printf("No\n"); return 0; } if (k==n-1) { if (as[0]==bs[0]) { for (i=1; i=n) { printf("Yes\n"); return 0; } } if (as[n-1]==bs[n-1]) { for (i=0; i=n-1) { printf("Yes\n"); return 0; } } if (as[0]==bs[1]) { s=1; e=n-1; while(s=n) { printf("Yes\n"); return 0; } } else if (as[n-1]==bs[n-2]) { s=0; e=n-2; while(s=n) { printf("Yes\n"); return 0; } } else if (as[0]==bs[n-2]) { s=0; e=n-2; while(s=n) { printf("Yes\n"); return 0; } s=1; e=n-1; while(s=n) { printf("Yes\n"); return 0; } } else if (as[n-1]==bs[1]) { s=1; e=n-1; while(s=n) { printf("Yes\n"); return 0; } s=0; e=n-2; while(s=n) { printf("Yes\n"); return 0; } } printf("No\n"); return 0; } printf("Yes\n"); } return 0; }