#include <bits/stdc++.h>   using namespace std;   long long a[200020];   long long va[200020];   long long b[200020];   long long c[200020];   char ans[200020];   char ansstring[200020];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     long long n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];       va[a[i]] = i;     }     for (int i = 1; i <= n; i++) {       cin >> b[i];       c[i] = va[b[i]];     }     char ch =  a ;     for (int i = 1; i <= n; i++) {       long long reach = c[i];       if (ch >  z ) {         ch--;       }       for (int j = i; j <= reach; j++) {         reach = max(reach, c[j]);         ans[j] = ch;       }       i = reach;       ch++;     }     if (ch -  a  < k) {       cout <<  NO ;       return 0;     }     for (int i = 1; i <= n; i++) {       ansstring[b[i]] = ans[i];     }     cout <<  YES n ;     for (int i = 1; i <= n; i++) {       cout << ansstring[i];     }   }   