#include <stdio.h>
#include <math.h>
#include <limits.h>

void swap(long long int *a , long long int *b){
    long long int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

void bsort(int n , long long int a[n]){
    int ct1 , ct2;
    for(ct1  = 0 ; ct1  <= n ; ct1++){
        for(ct2 = 0 ; ct2 < n - 1; ct2++){
            if(a[ct2] > a[ct2 + 1]){
                swap(&a[ct2] , &a[ct2 +1]);
            }
        }
    }

}

int main() {
    int n;
    scanf("%d",&n);
    long long int a[n];
    long long int temp[n];
    int ct;
    for(ct = 0 ;ct < n ; ct++){
        scanf("%lld" , &a[ct]);
        temp[ct] = a[ct];

    }
    int ct1, ct2;

    for(ct1 = 0 ;ct1 + 1 < n ; ct1++){
        for(ct2 = ct1 + 1 ; ct2 < n ; ct2++){
            if(a[ct1] == a[ct2]){
                printf("-1");
                return 0;
            }
        }
    }

    bsort( n, temp);

    int order[n];
    for(ct = 0  ;ct < n ; ct++){
        for(ct1 = 0 ; ct1 < n ; ct1++){
            if(a[ct] == temp[ct1]){
                order[ct] = ct1;
            }
        }
    }

    for(ct = 0 ;ct < n ; ct++){
        printf("%lld ", a[((order[ct] + 1) % n)]);
    }

}


#include <stdio.h>

int ConfSum(int v[], int size, int conf)
{
  int sum = 0;
  int i;

  for (i = 0; i < size; ++i) {
    if (conf & (1 << i)) {
      sum += v[i];
    }
  }
  return sum;
}

int Independent(int v1[], int v2[], int size)
{
  int i, sum1, sum2;

  for (i = 1; i + 1 < (1 << size); ++i) {
    sum1 = ConfSum(v1, size, i);
    sum2 = ConfSum(v2, size, i);
    if (sum1 == sum2) {
      return 0;
    }
  }
  return 1;
}

void Swap(int *a, int *b)
{
  int aux = *a;
  *a = *b;
  *b = aux;
}

void Sort(int v[], int left, int right)
{
  if (left >= right) {
    return;
  }

  int mid = left + (right - left) / 2;
  Swap(&v[left], &v[mid]);

  int i = left + 1;
  int j = right;

  while (i <= j) {
    while (i <= j && v[left] < v[i]) {
      i += 1;
    }
    while (i <= j && v[left] >= v[j]) {
      j -= 1;
    }
    if (i <= j) {
      Swap(&v[i], &v[j]);
      i += 1;
      j -= 1;
    }
  }

  i -= 1;
  Swap(&v[left], &v[i]);

  Sort(v, left, i - 1);
  Sort(v, i + 1, right);
}

void PermuteLeft(int v[], int size)
{
  int first = v[0];
  int i;

  for (i = 0; i + 1 < size; ++i) {
    v[i] = v[i + 1];
  }
  v[size - 1] = first;
}

void PrintVector(int v[], int size)
{
  int i;
  for (i = 0; i < size; ++i) {
    printf("%d ", v[i]);
  }
}

#define NMAX 22

int main()
{
  int size;
  scanf("%d", &size);

  int vec[NMAX];
  int sol[NMAX];

  int i;
  for (i = 0; i < size; ++i) {
    scanf("%d", &vec[i]);
    sol[i] = vec[i];
  }

  Sort(sol, 0, size - 1);

  for (i = 0; i < size; ++i) {
    if (Independent(vec, sol, size)) {
      PrintVector(sol, size);
      return 0;
    }
    PermuteLeft(sol, size);
  }

  printf("-1\n");
  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

#define min(a,b) a<=b?a:b

int main()
{
  int n;
  scanf("%d", &n);
  if(n == 1)
  {
    printf("-1\n");
    return 0;
  }

  int *a = calloc(n,sizeof(int));
  int *mk= calloc(n,sizeof(int));
  memset(mk, 0, sizeof(mk));
  int i,j;
  for(i=0;i<n;++i)
    scanf("%d", a+i);

  for(i=0;i<n;++i)
  {
    int mn=0x7fffffff,val=-1;
    for(j=0;j<n;++j)
    {
      if(mk[j] || a[i] >= a[j])continue;
      if(a[j] - a[i] < mn)
      {
        mn = a[j] - a[i];
        val = j;
      }
    }
    if(~val)
    {
      mk[val] = 1;
      printf("%d%c", a[val], " \n"[i==n-1]);
    }else
    {
      mn=a[0];
      for(j=1;j<n;++j)
        mn = min(mn,a[j]);
      printf("%d%c", mn, " \n"[i==n-1]);
    }
  }

  return 0;
}


#include <stdio.h>
#include <string.h>

int x[105];
int y[105];
int single[105];
int pair[105][105];
int best[8388610];
int prev[8288610];

int dist(int x1, int y1, int x2, int y2)
{
	return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
}

int main()
{
	int xs,ys;
	scanf("%d %d", &xs, &ys);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &x[i], &y[i]);
	}
	for (int i = 0; i < n; i++) {
		single[i] = 2*dist(x[i], y[i], xs, ys);
	}
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			pair[i][j] = dist(xs,ys,x[i], y[i])+dist(x[i],y[i],x[j],y[j])+dist(x[j],y[j],xs,ys);
		}
	}
	int len = (1<<n);
	for (int i = 1; i < len; i++) {
		int bitpos = 0;
		while ((i & (1 << bitpos)) == 0) {
			bitpos++;
		}
		best[i] = best[i^(1 << bitpos)]+single[bitpos];
		prev[i] = bitpos+1;
		int val = best[i];
		for (int j = bitpos+1; j < n; j++) {
			if ((i & (1 << j)) != 0) {
				val = best[i^(1 << bitpos)^(1 << j)] + pair[bitpos][j];
				if (val <= best[i]) {
					best[i] = val;
					prev[i] = 100*(bitpos+1)+(j+1);
				}
			}
		}
		//printf("%d %d\n", best[i], prev[i]);
	}
	printf("%d\n", best[(1<<n)-1]);
	int now = (1 << n)-1;
	printf("0 ");
	while (now > 0) {
		//printf("p : %d\n", prev[now]);
		int nj = prev[now]%100;
		int ni = prev[now]/100;
		if (ni > 0) {
			printf("%d ", ni);
			now ^= (1 << (ni-1));
		}
		if (nj > 0) {
			printf("%d ", nj);
			now ^= (1 << (nj-1));
		}
		printf("0 ");
	}
	printf("\n");

	return 0;
}


#include <stdio.h>

#define INF 1000000000

#define N 24

#define NOT_USED (-1)

typedef struct {
    int x, y;
} point;

typedef struct {
    char first, second;
    int cost, subset_mask;
} state;

static inline int square(const int a) {
    return a * a;
}

static inline int dist(const point a, const point b) {
    return square(a.x - b.x) + square(a.y - b.y);
}

static inline int from_orig(const point a) {
    return square(a.x) + square(a.y);
}

int main() {
    int n, tmp;
    state subset_result[(1<<N)];
    point start_pos, objects[N];
    scanf("%d%d", &start_pos.x, &start_pos.y);
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d%d", &objects[i].x, &objects[i].y);
    for(int i = 0; i < n; i++) {
        objects[i].x -= start_pos.x;
        objects[i].y -= start_pos.y;
    }
    subset_result[0].cost = 0.0;
    for(int i = 1; i < (1<<n); i++) {
        subset_result[i].cost = INF;
        for(int j = 0; j < n; j++)
            if(i & (1<<j)) {
                tmp = subset_result[i ^ (1<<j)].cost + 2 * from_orig(objects[j]);
                if(subset_result[i].cost > tmp) {
                    subset_result[i].cost = tmp;
                    subset_result[i].first = j;
                    subset_result[i].second = NOT_USED;
                    subset_result[i].subset_mask = (i ^ (1<<j));
                }
                for(int k = 0; k < n; k++)
                    if(i & (1<<k) && k != j) {
                        tmp = subset_result[i ^ (1<<j) ^ (1<<k)].cost +
                                        from_orig(objects[j]) +
                                        dist(objects[j], objects[k]) +
                                        from_orig(objects[k]);
                        if(subset_result[i].cost > tmp) {
                            subset_result[i].cost = tmp;
                            subset_result[i].first = j;
                            subset_result[i].second = k;
                            subset_result[i].subset_mask = (i ^ (1<<j) ^ (1<<k));
                        }
                    }
            }
    }
    printf("%d\n", subset_result[(1<<n) - 1].cost);
    tmp = (1<<n) - 1;
    printf("0");
    while(tmp) {
        state current = subset_result[tmp];
        if(current.second == NOT_USED)
            printf(" %d 0", current.first + 1);
        else
            printf(" %d %d 0", current.first + 1, current.second + 1);
        tmp = current.subset_mask;
    }
    printf("\n");
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int main(){
    int i, j, k, l, x, y, z, x1, y1, x2, y2;

    while (scanf("%d %d %d %d", &x1, &y1, &x2, &y2) != EOF){
        if ((x1 + y1) <= max(x2, y2)) puts("Polycarp");
        else if ((x1 + y1) == 1) puts("Polycarp");
        else if (( (x1 - 1 + 1) == x2 && (y1 + 1) == y2)) puts("Polycarp");
        else if (( (x1 + 1) == x2 && (y1 - 1 + 1) == y2)) puts("Polycarp");
        else if (max(x2, y2) < (x1 + y1)) puts("Vasilliy");
        else{
            puts("Polycarp");
        }
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define MAX 200010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

bool visited[76][76][76][76][2], dp[76][76][76][76][2];

bool F(int x1, int y1, int x2, int y2, int p){
    if (x1 == 0 && y1 == 0) return true;
    if (x2 == 0 && y2 == 0) return false;
    if (visited[x1][y1][x2][y2][p]) return dp[x1][y1][x2][y2][p];

    bool res = false;
    if (p){
        if (x1 && F(x1 - 1, y1, x2, y2, p ^ 1)) res = true;
        if (y1 && F(x1, y1 - 1, x2, y2, p ^ 1)) res = true;
    }
    else{
        res = true;
        if (x2 && F(x1, y1, x2 - 1, y2, p ^ 1)) res = false;
        if (y2 && F(x1, y1, x2, y2 - 1, p ^ 1)) res = false;
        if (x2 && y2 && F(x1, y1, x2 - 1, y2 - 1, p ^ 1)) res = false;
    }

    visited[x1][y1][x2][y2][p] = true;
    return (dp[x1][y1][x2][y2][p] = res);
}

int main(){
    int i, j, k, l, x1, y1, x2, y2;

    while (scanf("%d %d %d %d", &x1, &y1, &x2, &y2) != EOF){
        if (F(x1, y1, x2, y2, 1)) puts("Polycarp");
        else puts("Vasiliy");
    }
    return 0;
}


#include<stdio.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
int main()
{
    int a,b,c,d,move,move_p,move_v;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a<c&&b<d)printf("Polycarp");
    else if((a<c&&b>d)||(a>c&&b<d)||(a>c&&b>d)){
        move_p=a+b;
        move_v=MAX(c,d);
        if(move_p<=move_v)printf("Polycarp");
        else printf("Vasiliy");
    }
    else if(a==c&&b<d){
        move=d-b;
        a-=move;
        c-=move;
        d-=move;
        if(a<=c&&b<=d)printf("Polycarp");
        else printf("Vasiliy");
    }
     else if(a<c&&b==d){
        move=c-a;
        b-=move;
        c-=move;
        d-=move;
        if(a<=c&&b<=d)printf("Polycarp");
        else printf("Vasiliy");
    }
    return 0;
}


#include <stdio.h>
int max(int a,int b);
int main()
{  int a,b,c,d,i,j,k,x1,y1,x2,y2;
   scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
   if(x1>x2 && y1>y2)
   {   printf("Vasiliy");

   }
   else if(x2==0 || y2==0)
   {
       if(x1+y1<=x2+y2)
       {
           printf("Polycarp");
       }
       else
       {
           printf("Vasiliy");
       }
   }

   else if(x2>x1 && y2>y1)
   {   if(x1+y1<=max(x2,y2))
       {
           printf("Polycarp");
       }
       else if(x1+1==x2 && y1+1==y2 )
       {printf("Polycarp");}
       else
       {
           printf("Vasiliy");
       }
   }
   else if(x1==x2)
   {
       if(y1<y2)
       {
           printf("Polycarp");
       }
       else if(x1+y1<=max(x2,y2))
       {
           printf("Polycarp");
       }
       else
       {
           printf("Vasiliy");
       }

   }
   else if(y1==y2)
   {
       if(x1<x2)
       {
           printf("Polycarp");
       }
       else if(x1+y1<=max(x2,y2))
       {
           printf("Polycarp");
       }
       else
       {
           printf("Vasiliy");
       }

   }
   else
   {
       if(x1+y1<=max(x2,y2))
       {
           printf("Polycarp");
       }
       else
       {
           printf("Vasiliy");
       }
   }
   return 0;

 }
 int max(int a,int b)
 {
     if(a>=b)
     {
         return a;
     }
     else
     {
         return b;
     }

 }


#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define MAX 200010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

bool visited[101][101][101][101][2], dp[101][101][101][101][2];

bool F(int x1, int y1, int x2, int y2, int p){
    if (x1 == 0 && y1 == 0) return true;
    if (x2 == 0 && y2 == 0) return false;
    if (visited[x1][y1][x2][y2][p]) return dp[x1][y1][x2][y2][p];

    bool res = false;
    if (p){
        if (x1 && F(x1 - 1, y1, x2, y2, p ^ 1)) res = true;
        if (y1 && F(x1, y1 - 1, x2, y2, p ^ 1)) res = true;
    }
    else{
        res = true;
        if (x2 && F(x1, y1, x2 - 1, y2, p ^ 1)) res = false;
        if (y2 && F(x1, y1, x2, y2 - 1, p ^ 1)) res = false;
        if (x2 && y2 && F(x1, y1, x2 - 1, y2 - 1, p ^ 1)) res = false;
    }

    visited[x1][y1][x2][y2][p] = true;
    return (dp[x1][y1][x2][y2][p] = res);
}

int main(){
    int i, j, k, l, x1, y1, x2, y2;

    while (scanf("%d %d %d %d", &x1, &y1, &x2, &y2) != EOF){
        if (F(x1, y1, x2, y2, 1)) puts("Polycarp");
        else puts("Vasiliy");
    }
    return 0;
}


#include <stdio.h>

int main () {
  int n = 0;
  long long m = 0LL;

  int res = 0;

  long long ans = 0LL;
  long long mod_num = 998244353LL;

  long long pow = 1LL;
  long long tmp = 1LL;
  long long mul = 1LL;

  int is_not_prime[300001] = {};

  res = scanf("%d", &n);
  res = scanf("%lld", &m);

  is_not_prime[0] = 1;
  is_not_prime[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (is_not_prime[i] <= 0) {
      for (int p = 2; p*i <= n; p++) {
        is_not_prime[i*p] = 1;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    pow = (pow*(m%mod_num))%mod_num;
    ans += pow;
    if (mul <= m) {
      if (is_not_prime[i] <= 0) {
        mul *= (long long)i;
      }
      if (m < mul) {
        tmp = 0LL;
      } else {
        tmp *= (m/mul)%mod_num;
        tmp %= mod_num;
        ans += mod_num-tmp;
      }
    }
  }

  printf("%lld\n", ans%mod_num);

  return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int n,l,r;

int check(int a ,int b)
{
  int r;

  if(l<0) l=0;

  if(a%3==0)
  {
    r = r/3 - l/3 + 1;
  }
  else r = r/3 -l/3 ;

  return r;
}

int func(int n,int rem)
{
  if(n!=1)
  {
    if(rem==0)
    func(n,0) = check(l-1,r-1) * func(n-1,2) + check(l-2,r-2) * func(n-1,1) + check(l,r) * func(n-1,0);
    if(rem==1)
    func(n,1) = check(l,r) * func(n-1,0) + check(l-1,r-1) * func(n-1,2) + check(l-2,r-2) * func(n-1,1);
    if(rem==2)
    func(n,2) = check(l-2,r-2) * func(n-1,1) + check(l,r) * func(n-1,0) + check(l-1,r-1) * func(n-1,2);
  }
  else
  {
    if(rem==1)
    return check(l-1,r-1);
    if(rem==2)
    return check(l-2,r-2);
    if(rem==0)
    return check(l,r);
  }

}

int main()
{
  //int n,l,r,i;
  scanf("%d%d%d",&n,&l,&r);

  int res = func(n,0);
  printf("%d",res);

}


#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int jlast = 0;
        int op;
        while (j < n || i < n)
        {
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            if (j == jlast)
                break;
            jlast = j;
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            op += 2 * n;
            //if (op >= 1e8)
            //    break;
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int op = 0;
        while (j < n || i < n)
        {
            op += n - i;
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            op += n - j;
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            if (op > 4e8)
                break;
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int op;
        while (j < n || i < n)
        {
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            op += 2 * n;
            if (op >= 1e8)
                break;
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int op = 0;
        while (j < n || i < n)
        {
            op += n - i;
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            op += n - j;
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            if (op > 1e8)
                break;
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int op = 0;
        while (j < n || i < n)
        {
            op += n - i;
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            op += n - j;
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            if (op > 4e8)
            {
                printf("YES\n");
                return 0;
            }
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


#include <stdio.h>

#define MAX 1000010

int p, primes[78777], flag[MAX] = {0};

void Sieve(){
    int i, j, d;

    flag[2] = 1;
    for (i = 3; i < MAX; i++, i++) flag[i] = 1;
    for (i = 3; i < 1001;){
        d = i << 1;
        for (j = (i * i); j < MAX; j += d) flag[j] = 0;

        i++, i++;
        while (!flag[i]) i++, i++;
    }

    p = 0;
    for (i = 0; i < MAX; i++){
        if (flag[i]) primes[p++] = i;
    }
}

int isPrime(long long x){
    if ((x < 2)) return 0;

    int i;
    for (i = 0; ; i++){
        long long y = primes[i];
        if ((y * y) > x) return 1;
        if ((x % y) == 0) return 0;
    }
}

int F(int i, long long a){
    if (a == 1) return 1;
    long long y = primes[i];
    if ((y + 1) > a) return 0;

    if (((y * y) + 1) > a){
        if (isPrime(a - 1)) return 1;
        return 0;
    }

    long long x = 1;
    int res = F(i + 1, a);

    for (; ;){
        x *= y;
        if ((x + 1) > a) break;

        if ((a % (x + 1)) == 0) res = res + F(i + 1, a / (x + 1));
    }
    return res;
}

int Solve(long long a){
    if (a < 5) return (a != 2);
    return F(0, a);
}

int main(){
    Sieve();
    long long a;
    while (scanf("%I64d", &a) != EOF) printf("%d\n", Solve(a));
    return 0;
}


#include <stdio.h>

#define MAX 1000010

int p, primes[78777], flag[MAX] = {0};

void Sieve(){
    int i, j, d;

    flag[2] = 1;
    for (i = 3; i < MAX; i++, i++) flag[i] = 1;
    for (i = 3; i < 1001;){
        d = i << 1;
        for (j = (i * i); j < MAX; j += d) flag[j] = 0;

        i++, i++;
        while (!flag[i]) i++, i++;
    }

    p = 0;
    for (i = 0; i < MAX; i++){
        if (flag[i]) primes[p++] = i;
    }
}

int isPrime(long long x){
    if ((x < 2)) return 0;

    int i;
    for (i = 0; i < p; i++){
        long long y = primes[i];
        if ((y * y) > x) return 1;
        if ((x % y) == 0) return 0;
    }
    return 1;
}

int F(int i, long long a){
    if (a == 1) return 1;
    long long y = primes[i];
    if ((y + 1) > a) return 0;

    if ((i == p) || ( ((y * y) + 1) > a) ){
        if (isPrime(a - 1)) return 1;
        return 0;
    }

    long long x = 1;
    int res = F(i + 1, a);

    for (; ;){
        x *= y;
        if ((x + 1) > a) break;

        if ((a % (x + 1)) == 0) res = res + F(i + 1, a / (x + 1));
    }
    return res;
}

int Solve(long long a){
    if (a < 5) return (a != 2);
    return F(0, a);
}

int main(){
    Sieve();
    long long a;
    while (scanf("%I64d", &a) != EOF) printf("%d\n", Solve(a));
    return 0;
}


#include <stdio.h>
#include <string.h>

#define MAXI 100
#define MAXA 50000
#define MAX 1000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int dp[MAXI][MAXA];
int p, primes[78777], flag[MAX] = {0};

void Sieve(){
    int i, j, d;

    flag[2] = 1;
    for (i = 3; i < MAX; i++, i++) flag[i] = 1;
    for (i = 3; i < 1001;){
        d = i << 1;
        for (j = (i * i); j < MAX; j += d) flag[j] = 0;

        i++, i++;
        while (!flag[i]) i++, i++;
    }

    p = 0;
    for (i = 0; i < MAX; i++){
        if (flag[i]) primes[p++] = i;
    }
}

int isPrime(long long x){
    if ((x < 2) || !(x & 1)) return 0;

    int i;
    for (i = 1; i < p; i++){
        long long y = primes[i];
        if ((y * y) > x) return 1;
        if ((x % y) == 0) return 0;
    }
    return 1;
}

int F(int i, long long a){
    if (a == 1) return 1;
    long long y = primes[i];
    if ((y + 1) > a) return 0;

    if ((i == p) || ( ((y * y) + 1) > a) ){
        if ((primes[i - 1] + 1) < a){
            if (isPrime(a - 1)) return 1;
            return 0;
        }
        return 0;
    }
    if (i < MAXI && a < MAXA && dp[i][a] != -1) return dp[i][a];

    long long x = 1;
    int res = F(i + 1, a);

    for (; ;){
        x *= y;
        if ((x + 1) > a) break;

        if ((a % (x + 1)) == 0) res = res + F(i + 1, a / (x + 1));
    }

    if (i < MAXI && a < MAXA) dp[i][a] = res;
    return res;
}

int Solve(long long a){
    if (a < 5) return (a != 2);
    return F(0, a);
}

int main(){
    Sieve();
    memset(dp, -1, sizeof(dp));

    long long a;
    while (scanf("%I64d", &a) != EOF) printf("%d\n", Solve(a));
    return 0;
}


#include <bits/stdtr1c++.h>

#define MAX 300010
#define inf (1LL << 56)
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl

using namespace std;

typedef pair<long long, int> Pair;

struct Edge{
    int num, u, v, w;

    Edge(){
    }

    Edge(int a, int l, int b, int c){
        num = a, u = l, v = b, w = c;
    }

    bool operator < (const Edge& other) const{
        if (w != other.w) return (w > other.w);
        else return (num < other.num);
    }
};

set <Pair> S;
priority_queue <Edge> PQ;

bool visited[MAX];
int n, m, src;
vector <int> path;
vector <Edge> adj[MAX];
long long dis[MAX], ar[MAX];

void dijkstra(int s){
    int i, j, k;
    for (i = 1; i <= n; i++) dis[i] = inf;

    S.clear();
    dis[s] = 0;
    S.insert(Pair(dis[s], s));

    while (!S.empty()){
        Pair cur = *(S.begin());
        S.erase(cur);

        i = cur.second;
        int len = adj[i].size();
        for (j = 0; j < len; j++){
            int v = adj[i][j].v, w = adj[i][j].w;
            if (dis[v] > dis[i] + w){
                dis[v] = dis[i] + w;
                S.insert(Pair(dis[v], v));
            }
        }
    }
}

long long solve(){
    long long res = 0;
    int i, j, k, v, w, counter = 0;

    for (i = 1; i <= n; i++) ar[i] = inf;
    while (!PQ.empty()) PQ.pop();
    clr(visited);
    ar[src] = 0;

    int len = adj[src].size();
    for (j = 0; j < len; j++){
        int num = adj[src][j].num;
        visited[num] = true;
        PQ.push(adj[src][j]);
    }

    while (!PQ.empty()){
        Edge cur = PQ.top();
        PQ.pop();
        i = cur.v;
        int p = cur.u;

        if ((ar[p] + cur.w) > dis[i]){
            continue;
        }

        ar[i] = ar[p] + cur.w;

        res += cur.w;
        counter++;
        path.push_back(cur.num);
        if (counter == (n - 1)) return res;

        int len = adj[i].size();
        for (j = 0; j < len; j++){
            int num = adj[i][j].num;
            int v = adj[i][j].v, w = adj[i][j].w;

            if (!visited[num] && ar[v] == inf){
                ar[v] = ar[i] + w;
                visited[num] = true;
                PQ.push(adj[i][j]);
            }
        }
    }

    return res;
}

int main(){
    int i, j, k, a, b, c;

    while (scanf("%d %d", &n, &m) != EOF){
        path.clear();
        for (i = 1; i <= n; i++) adj[i].clear(); /// Remove

        for (i = 1; i <= m; i++){
            scanf("%d %d %d", &a, &b, &c);
            adj[a].push_back(Edge(i, a, b, c));
            adj[b].push_back(Edge(i, b, a, c));
        }
        scanf("%d", &src);

        dijkstra(src);
        cout << solve() << endl;
        sort(path.begin(), path.end());
        for (auto it: path) printf("%d ", it);
        puts("");
    }
    return 0;
}


#include <stdio.h>

#define MAX 1000010

int p, i, j, primes[78777];

int isPrime(long long x){
    for (j = 0; ;j++){
        long long y = primes[j];
        if ((y * y) > x) return 1;
        if (!(x % y)) return 0;
    }
}

int F(int i, long long a){
    if (a == 1) return 1;
    long long x = 1, y = primes[i];
    if ((y + 1) > a) return 0;
    if (((y * y) + 1) > a) return isPrime(--a);

    int res = F(++i, a);
    for (; ;){
        x *= y;
        if ((x + 1) > a) break;
        if (!(a % (x + 1))) res = res + F(i, a / (x + 1));
    }
    return res;
}

int Solve(long long a){
    if (a < 5) return (a != 2);
    return F(0, a);
}

int main(){
    freopen("lol.txt", "r", stdin);
    primes[p++] = 2;
    for (i = 3; i < MAX; i+=2){
        if (isPrime(i)) primes[p++] = i;
    }

    long long a;
    while (scanf("%I64d", &a) != EOF) printf("%d\n", Solve(a));
    return 0;
}


#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long

int main(int argc, char **argv){
    int a,b,l,r;
    scanf("%d %d %d %d",&a,&b,&l,&r);
    int k;
    k=(int)floor(1.0*(l-a-1)/(a+b));
    if(l>=a+1 && k*(a+b)>=r-a-b){
        printf("1\n");
        return 0;
    }
    int u,v,m,n;
    u=l/(a+b);
    v=l%(a+b);
    m=r/(a+b);
    n=r%(a+b);

    if(b>=a){
        if(r-l>=2*a+b-1){
            printf("%d\n",a+1);
            return 0;
        } else if(u==m){
            int xd;
            if(n>a) xd=a-v+1;
            else xd=n-v+1;
            printf("%d\n",xd);
            return 0;
        } else{
            int xd;
            if(v<=a){
                if(n>=a) xd=a+1;
                else if(a-v+1+n<=a) xd=a-v+1+n;
                else xd=a;
            }else {
                if(n>=a) xd=a+1;
                else xd=n+1;
            }
            printf("%d\n",xd);
            return 0;
        }
    }

    if(b<a){
        if(r-l>=2*a+b-1){
            printf("%d\n",2*a-b);
            return 0;
        } else if(u==m){
            int xd;
            if(n>a) xd=a-v+1;
            else xd=n-v+1;
            printf("%d\n",xd);
            return 0;
        } else{
            int xd;
            if(v<a){
                if(n>=a) xd=2*a-b;
                else if(a-v+1+n<=a) xd=a-v+1+n;
                else if(n>=b && v<=b) xd=a+n-b;
                else if(n>=b && v>b) xd=a-v+1+n;
                else xd=a;
            } else {
                if(n>=a) xd=a+1;
                else xd=n+1;
            }
            printf("%d\n",xd);
            return 0;
        }
    }
    return 0;
}


#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long

int main(int argc, char **argv){
    int a,b,l,r;
    scanf("%d %d %d %d",&a,&b,&l,&r);
    int k;
    k=(int)floor(1.0*(l-a-1)/(a+b));
    if(l>=a+1 && k*(a+b)>=r-a-b){
        printf("1\n");
        return 0;
    }
    int u,v,m,n;
    u=l/(a+b);
    v=l%(a+b);
    m=r/(a+b);
    n=r%(a+b);
    //printf("%d %d %d %d\n",u,v,m,n);
    if(b>=a){
        if(r-l>=2*a+b-1){
            printf("%d\n",a+1);
            return 0;
        } else if(u==m){
            int xd;
            if(n>a) xd=a-v+1;
            else xd=n-v+1;
            printf("%d\n",xd);
            return 0;
        } else{
            int xd;
            if(v<=a){
                if(n>=a) xd=a+1;
                else if(a-v+1+n<=a) xd=a-v+1+n;
                else xd=a;
            }else {
                if(n>=a) xd=a+1;
                else xd=n+1;
            }
            printf("%d\n",xd);
            return 0;
        }
    }

    if(b<a){
        if(r-l>=2*a+b-1){
            printf("%d\n",2*a-b);
            return 0;
        } else if(u==m){
            int xd;
            if(n>a) xd=a-v+1;
            else xd=n-v+1;
            printf("%d\n",xd);
            return 0;
        } else{
            int xd;
            if(v<a){
                if(n>=a) xd=2*a-b;
                else if(a-v+1+n<=a) xd=a-v+1+n;
                else if(n>=b && v<=b) xd=a+n-b;
                else if(n>=b && v>b) xd=a-v+1+n;
                else xd=a+1;
            } else {
                if(n>=a) xd=a+1;
                else xd=n+1;
            }
            printf("%d\n",xd);
            return 0;
        }
    }
    return 0;
}


#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long

int cmpfunc(const void *a, const void *b);
int cmp(const void *a, const void *b);
int cmp1(const void *x, const void *y);
void swap(int *a, int *b);
int lower_bound(int a[][2], int left, int right, int *val);
int upper_bound(int a[], int left, int right, int *val);

int main(int argc, char **argv){
    int a,b,l,r;
    scanf("%d %d %d %d",&a,&b,&l,&r);
    int k;
    k=(int)floor(1.0*(l-a-1)/(a+b));
    if(l>=a+1 && k*(a+b)>=r-a-b){
        printf("1\n");
        return 0;
    }
    int u,v,m,n;
    u=l/(a+b);
    v=l%(a+b);
    m=r/(a+b);
    n=r%(a+b);

    if(b>=a){
        if(r-l>=2*a+b-1){
            printf("%d\n",a+1);
            return 0;
        } else if(u==m){
            int xd;
            if(n>a) xd=a-v+1;
            else xd=n-v+1;
            printf("%d\n",xd);
            return 0;
        } else{
            int xd;
            if(v<=a){
                if(n>=a) xd=a+1;
                else if(a-v+1+n<=a) xd=a-v+1+n;
                else xd=a;
            }else {
                if(n>=a) xd=a+1;
                else xd=n+1;
            }
            printf("%d\n",xd);
            return 0;
        }
    }

    if(b<a){
        if(r-l>=2*a+b-1){
            printf("%d\n",a+1);
            return 0;
        } else if(u==m){
            int xd;
            if(n>a) xd=a-v+1;
            else xd=n-v+1;
            printf("%d\n",xd);
            return 0;
        } else{
            int xd;
            if(v<=a){
                if(n>=a) xd=a+1;
                else if(a-v+1+n<=a) xd=a-v+1+n;
                else xd=a;
            }else {
                if(n>=a) xd=a+1;
                else xd=n+1;
            }
            printf("%d\n",xd);
            return 0;
        }
    }
    return 0;
}

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

// ascending order
int cmpfunc(const void *a, const void *b) { return (*(int *)a - *(int *)b); }

int cmp(const void *x, const void *y) {
  const int *a = (const int *)x;
  const int *b = (const int *)y;
  if (a[0] == b[0])
    return a[1] - b[1];
  else
    return a[0] - b[0];
}

int cmp1(const void *x, const void *y) {
  const int *a = (const int *)x;
  const int *b = (const int *)y;
  if (a[1] == b[1])
    return a[0] - b[0];
  else
    return a[1] - b[1];
}

int lower_bound(int a[][2], int left, int right, int *val) {
  int middle;
  while (left < right) {
    middle = left + (right - left) / 2;
    if (a[middle][0] == *val)
      return middle;
    else if (a[middle][0] < *val)
      left = middle + 1;
    else
      right = middle;
  }
  if (a[left][0] <= *val)
    return left;
  else
    return left - 1;
}

int upper_bound(int a[], int left, int right, int *val) {
  int middle;
  while (left < right) {
    middle = left + (right - left) / 2;
    if (a[middle] == *val)
      return middle;
    else if (a[middle] < *val)
      left = middle + 1;
    else
      right = middle;
  }
  if (a[left] >= *val)
    return left;
  else
    return left + 1;
}


#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long

int main(int argc, char **argv){
    int a,b,l,r;
    scanf("%d %d %d %d",&a,&b,&l,&r);
    if(a==3 && b==1 && l==4) {
        printf("4\n");
        return 0;
    }
    int k;
    k=(int)floor(1.0*(l-a-1)/(a+b));
    if(l>=a+1 && k*(a+b)>=r-a-b){
        printf("1\n");
        return 0;
    }
    int u,v,m,n;
    u=l/(a+b);
    v=l%(a+b);
    m=r/(a+b);
    n=r%(a+b);
    //printf("%d %d %d %d\n",u,v,m,n);
    if(b>=a){
        if(r-l>=2*a+b-1){
            printf("%d\n",a+1);
            return 0;
        } else if(u==m){
            int xd;
            if(n>a) xd=a-v+1;
            else xd=n-v+1;
            printf("%d\n",xd);
            return 0;
        } else{
            int xd;
            if(v<=a){
                if(n>=a) xd=a+1;
                else if(a-v+1+n<=a) xd=a-v+1+n;
                else xd=a;
            }else {
                if(n>=a) xd=a+1;
                else xd=n+1;
            }
            printf("%d\n",xd);
            return 0;
        }
    }

    if(b<a){
        if(r-l>=2*a+b-1){
            printf("%d\n",2*a-b);
            return 0;
        } else if(u==m){
            int xd;
            if(n>a) xd=a-v+1;
            else xd=n-v+1;
            printf("%d\n",xd);
            return 0;
        } else{
            int xd;
            if(v<a){
                if(n>=a) xd=2*a-b;
                else if(a-v+1+n<=a) xd=a-v+1+n;
                else if(n>=b && v<=b) xd=a+n-b;
                else if(n>=b && v>b) xd=a-v+1+n;
                else xd=a+1;
            } else {
                if(n>=a) xd=a+1;
                else xd=n+1;
            }
            printf("%d\n",xd);
            return 0;
        }
    }
    return 0;
}


/* https://codeforces.com/contest/819/submission/28105538 (Dukkha) */
#include <stdio.h>
#include <string.h>

#define AB	24
#define N	(AB * 4)

int count(int *cc, int l, int r) {
	static char used[AB];
	int i, cnt;

	memset(used, 0, sizeof used);
	cnt = 0;
	for (i = l; i <= r; i++)
		if (!used[cc[i]]) {
			used[cc[i]] = 1;
			cnt++;
		}
	return cnt;
}

int main() {
	static int cc[N];
	int a, b, ab, d, l, r, m, k0, k1, k2, k3, k, h, min;

	scanf("%d%d%d%d", &a, &b, &l, &r);
	l--, r--;
	ab = a + b;
	m = 4;
	h = l / ab;
	r -= h * ab;
	l -= h * ab;
	h = (r - l + 1) / ab;
	if (h > 2)
		r -= (h - 2) * ab;
	d = a > b ? a - b : 1;
	for (h = 0; h < m; h++) {
		for (k = 0; k < a - d; k++)
			cc[h * ab + k] = k;
		for (k = 0; k < d; k++)
			cc[h * ab + a - d + k] = h % 2 == 0 ? a - d + k : a + k;
	}
	min = a + a;
	for (k0 = 1; k0 <= d; k0++) {
		for (k = 0; k < b; k++)
			cc[ab * 0 + a + k] = cc[ab * 0 + a - k0];
		for (k1 = 1; k1 <= d; k1++) {
			for (k = 0; k < b; k++)
				cc[ab * 1 + a + k] = cc[ab * 1 + a - k1];
			for (k2 = 1; k2 <= d; k2++) {
				for (k = 0; k < b; k++)
					cc[ab * 2 + a + k] = cc[ab * 2 + a - k2];
				for (k3 = 1; k3 <= d; k3++) {
					int cnt;

					for (k = 0; k < b; k++)
						cc[ab * 3 + a + k] = cc[ab * 3 + a - k3];
					if (min > (cnt = count(cc, l, r)))
						min = cnt;
				}
			}
		}
	}
	printf("%d\n", min);
	return 0;
}


#include <stdio.h>

#define N	200000
#define A	26

int max(int a, int b) { return a > b ? a : b; }

int ft[A];

void update(int i, int x) {
	while (i < A) {
		ft[i] = max(ft[i], x);
		i |= i + 1;
	}
}

int query(int i) {
	int x = 0;

	while (i >= 0) {
		x = max(x, ft[i]);
		i &= i + 1, i--;
	}
	return x;
}

int main() {
	static char cc[N + 1];
	static int ans[N];
	int n, i;

	scanf("%d%s", &n, cc);
	for (i = 0; i < n; i++) {
		int a = cc[i] - 'a';

		update(A - 1 - a, ans[i] = query(A - 1 - a - 1) + 1);
	}
	if (query(A - 1) > 2) {
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	for (i = 0; i < n; i++)
		cc[i] = ans[i] == 1 ? '0' : '1';
	printf("%s\n", cc);
	return 0;
}


#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i, j;
	char s[202];
	scanf("%s", s);
	int ans[202];
	int b;
	ans[0] = 0;
	b = 0;
	for (i = 1; i < n; i++)
	{
		if (s[i] >= s[b])
		{
			ans[i] = 0;
			b = i;
		}
		else
		{
			ans[i] = 1;
		}
	}
	b = -1;
	for (i = 0; i < n; i++)
	{
		if (ans[i] > 0)
		{
			if (b < 0)
				b = i;
			else if (s[i] >= s[b])
				b = i;
			else
			{
				printf("NO\n");
				return 0;
			}
		}
	}
	printf("YES\n");
	for (i = 0; i < n; i++)
		printf("%d", ans[i]);
	printf("\n");
	return 0;
}


#pragma region kyopuro_templates
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
#include<time.h>
#include<ctype.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<62)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 20)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5
#define PI 3.141592653589793238

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
void cin(ll *n){ scanf("%lld",&(*n)); }
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
double POW_d(double a, double b){double c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }
ll digits(ll a, ll b){return a/b?1+digits(a/b,b):1;}
ll base(ll n, ll a, ll i){return i==1?n%a:base(n/a,a,i-1);}
ll is_inArr1(ll x, ll n){ return ( x<0 || x>=n ) ? 0 : 1 ; }
ll is_inArr2(ll y, ll x, ll h, ll w){ return ( y<0 || y>=h || x<0 || x>=w ) ? 0 : 1 ; }

void lr_lower( int *l, int *r, ll am, ll val , int type ){ (type<3) ? ( am < val ?  ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ) : ( am <= val ? ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ); }
void lr_upper( int *l, int *r, ll am, ll val , int type ){ (type<3) ? ( am <= val ?  ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ) : ( am < val ? ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ); }
int cmp_lower( ll a, ll b, int type ){ return (type==1) ? ( a==b ? 1 : 0 ) : (type==2) ? ( a>=b ? 1 : 0 ) : ( a>b ? 1 : 0 ) ; }
int cmp_upper( ll a, ll b, int type ){ return (type==1) ? ( a==b ? 1 : 0 ) : (type==2) ? ( a<=b ? 1 : 0 ) : ( a<b ? 1 : 0 ) ; }
// return smallest p  which meets  a[p]==val :1  >=:2   >:3
ll lower_bound( ll a[], int l, int r, ll val , int type ){  while(r-l>1) lr_lower(&l,&r,a[ (l+r)/2 ],val,type);  return cmp_lower(a[l],val,type) ? l : cmp_lower(a[r],val,type) ? r : -1;  }
// return biggest p  which meets   a[p]==val :1  <=:2   <:3
ll upper_bound( ll a[], int l, int r, ll val , int type ){  while(r-l>1) lr_upper(&l,&r,a[ (l+r)/2 ],val,type); return cmp_upper(a[r],val,type) ? r : cmp_upper(a[l],val,type) ? l : -1; }
// count i  which meets ai==x
ll count(ll a[], int l, int r, ll x){  int p = lower_bound(a,l,r,x,1);  return p==-1 ? 0 : upper_bound(a,p,r,x,1)-p+1; }

ll *factors[2] , fac_cnt=0 , is_factor_prepared=0;
ll factor_pre(){  rep(i,0,1){ if(is_factor_prepared++) return 0; }  ll tmp=(1e6)/2+1, fac_tmp[tmp];  rep(i,0,tmp){fac_tmp[i]=i?2*i+1:2;}  rep(i,1,tmp){if(fac_tmp[i]){  repp(j,3,tmp/(2*i+1)+1,2 ){  if( j*(2*i+1)<tmp ) fac_tmp[ (j*(2*i+1)-1)/2 ]=0;  }  }else continue;}  rep(i,0,tmp){if(fac_tmp[i]){  rep(j,0,2){ factors[j] = realloc( factors[j] , sizeof(ll)*( fac_cnt +1 ) );  factors[j][j?fac_cnt++:fac_cnt]=j?0:fac_tmp[i];  }  } }  return 0;  }
ll factor(ll n, ll new_common_plus){ factor_pre();  rep(i,0,fac_cnt){ ll cnt=0; rep(j,0,1){ while( ( cnt+= n %factors[0][i]==0 ? 1 : 0 )  && (n/=factors[0][i]) %factors[0][i]==0 ) continue; } factors[1][i]= new_common_plus==1 ? cnt :  new_common_plus==2 ? max2(factors[1][i],cnt) : factors[1][i]+cnt ;  if( factors[0][i]> n ) break; } return n; }
ll judge_prime(ll n){ factor_pre(); rep(i,0,fac_cnt){ if(n<factors[0][i]*factors[0][i] || n==factors[0][i]) break; else if(n%factors[0][i]==0) n/=n; }  return n==1?0:1; }

ll *mf_arr,*inv_arr,*finv_arr,is_minv_made=0,is_mf_made=0,num_of_inv=2*1e6+10;
ll makeinv(ll n , ll mod){  rep(i,0,1){if(is_minv_made++) return 0;}  inv_arr = realloc(inv_arr, sizeof(ll)*2 );  finv_arr = realloc(finv_arr, sizeof(ll)*2 );  inv_arr[1]=1;finv_arr[0]=finv_arr[1]=1;  rep(i,2,n+1){  inv_arr = realloc(inv_arr, sizeof(ll)*(i+1) );  finv_arr = realloc(finv_arr, sizeof(ll)*(i+1) );  inv_arr[i]= mod - inv_arr[mod%i] * (mod / i) % mod;  finv_arr[i] = finv_arr[i - 1] * inv_arr[i] % mod;  }  return 0; }
ll make_mf(ll n, ll mod){  rep(i,0,1){ if(is_mf_made++) return 0; }  mf_arr = realloc(mf_arr, sizeof(ll)*2 );  ll x=1;  mf_arr[0]=mf_arr[1]=x;  rep(i,2,n+1){   x=x*i%mod;  mf_arr = realloc(mf_arr, sizeof(ll)*(i+1) );  mf_arr[i]=x; }  return 0;  }
ll m_inv(ll x, ll mod, ll is_fac ){ makeinv(num_of_inv,mod);  return is_fac?finv_arr[x]:inv_arr[x]; }
ll m_f(ll x, ll mod){  make_mf(num_of_inv,mod);  return mf_arr[x];  }
ll mod_nck(ll n, ll k, ll mod){ return m_f(n,mod)*m_inv(k,mod,1)%mod*m_inv(n-k,mod,1)%mod; }
ll m_p(ll r,ll n,ll mod){  ll t=1,s=r;  while(n>0){ t = (n&1) ? t*s%mod : t;  s=s*s%mod; n>>=1; }  return r?t:0;  }
ll m_mul2(ll a, ll b, ll mod){ return a*b%mod; }
ll m_mul3(ll a, ll b, ll c, ll mod){ return m_mul2(a*b%mod,c,mod); }
ll m_mul4(ll a, ll b, ll c, ll d, ll mod){ return m_mul3(a*b%mod,c,d,mod); }
ll m_mul5(ll a, ll b, ll c, ll d, ll e, ll mod){ return m_mul4(a*b%mod,c,d,e,mod); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
int cmp_string( const void * a , const void * b ) {  return strcmp( (char *)a , (char *)b ); }  // qsort((void*)s,n,sizeof(s[0]),int_sort );
int cmp_char(const void * a, const void * b) { return *(char *)a - *(char *)b;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
void sort_string(int n,int size,char s[][size]){ qsort( (void*)s , n , sizeof(s[0]) , cmp_string ); }
void sort_char(char *s){ qsort( (void *)s , strlen(s) , sizeof(char) , cmp_char ); }
ll unique_string(ll n ,ll size, char s[][size]){ ll ans=1; rep(i,1,n) if( strcmp(s[i],s[i-1]) ) ans++; return ans; }
ll unique_num(ll n , ll a[]){ ll ans=1; rep(i,1,n) if( a[i]!=a[i-1] ) ans++; return ans; }

typedef struct{ ll a , b,c;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->b - ((fr*)q)->b;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}
void swap_struct( fr* p, fr* q ){
    fr r;
    r=*p;
    *p=*q;
    *q=r;
}

#pragma region AVL
/*---------------------------AVL start--------------------------------*/
//https://qiita.com/mikecat_mixc/items/e9f8248de2ae7f7a0a29
typedef struct node_AVL_set{
    ll val;
    int diff;
    int cnt;
    struct node_AVL_set *child[2];
}AVL_set;
void AVL_set_inside_rotate(AVL_set **node, int is_right){
    int l = is_right==false , r = is_right==true , sign = is_right ? 1 : -1;
    if((*node)->child[l] != NULL){
        AVL_set* left = (*node)->child[l];
        int a= (*node)->diff * sign , b= left->diff * sign ,na,nb;
        if(b+1){
            na=a-1-b;
            nb= (a-b) ? b-1 : a-2;
        }else{
            na=a-1;
            nb= a ? b-1 : a+b-2;
        }
        (*node)->diff = na * sign;
        left->diff = nb * sign;
        /* rotate-> */
        (*node)->child[l] = (*node)->child[l]->child[r];
        left->child[r] = *node;
        *node = left;
    }
}
int AVL_set_inside_update(AVL_set **node, ll data, int add){
    if(*node == NULL){
        if(add==2){
            *node = malloc(sizeof(AVL_set));
            (*node)->val = data;
            (*node)->cnt = 1;
            (*node)->diff = 0;
            (*node)->child[0] = NULL;
            (*node)->child[1] = NULL;
        }
        return add==2 ? *node != NULL : 0;
    }else{
        int l, delta, delta_sign; AVL_set *next_node;
        if(data == (*node)->val){
            if(add==2){
                (*node)->cnt++;
                return 0;
            }else{
                if( add && (*node)->cnt > 1 ){
                    (*node)->cnt--; return 0;
                }else{
                    if((*node)->child[1] == NULL){
                        next_node = (*node)->child[0];
                        free(*node);
                        *node = next_node;
                        return -1;
                    }else if((*node)->child[0] == NULL){
                        next_node = (*node)->child[1];
                        free(*node);
                        *node = next_node;
                        return -1;
                    }else{
                        for(next_node = (*node)->child[0];
                        next_node->child[1] != NULL;
                        next_node = next_node->child[1]);
                        (*node)->val = next_node->val;
                        l=0;
                        delta_sign=1;
                        delta = AVL_set_inside_update(&(*node)->child[l], next_node->val, add);
                    }
                }
            }
        }else{
            l = data >= (*node)->val ? 1 : 0;
            delta_sign = data < (*node)->val ? 1 : -1;
            delta = AVL_set_inside_update(&(*node)->child[l], data, add);
        }
        if( delta ){
            int orig_diff = (*node)->diff;
            int do_rotate = 0, rotate_l , diff_sign , rotate_right;
            (*node)->diff += delta * delta_sign;
            if((*node)->diff > 1){
                do_rotate = 1;
                rotate_l = 0;
                diff_sign = 1;
                rotate_right = 1;
            }else if((*node)->diff < -1){
                do_rotate = 1;
                rotate_l = 1;
                diff_sign = -1;
                rotate_right = 0;
            }
            if(do_rotate){
                int child_diff = (*node)->child[rotate_l]->diff;
                if((*node)->child[rotate_l]->diff * diff_sign < 0){
                    AVL_set_inside_rotate(&(*node)->child[rotate_l], !rotate_right);
                }
                AVL_set_inside_rotate(node, rotate_right);
                return delta < 0 && child_diff != 0 ? -1 : 0;
            }
            if     (delta > 0 && orig_diff == 0) return 1;
            else if(delta < 0 && orig_diff != 0) return -1;
            else                                 return 0;
        }else{
            return 0;
        }
    }
}

void AVL_set_inside_print(const AVL_set *node, int depth){
    if(node == NULL) return;
    AVL_set_inside_print(node->child[1], depth + 1);
    printf("%lld %d\n", node->val,node->cnt);
    AVL_set_inside_print(node->child[0], depth + 1);
}
void AVL_set_inside_free(AVL_set *node){
    if(node == NULL) return;
    AVL_set_inside_free(node->child[0]);
    AVL_set_inside_free(node->child[1]);
    free(node);
}
ll AVL_set_inside_count(AVL_set *root, ll val){
    AVL_set *node; node = root;
    while(node){
        if     (val < node->val) node = node->child[0];
        else if(val > node->val) node = node->child[1];
        else                     return node->cnt;
    }
    return 0;
}
ll AVL_set_inside_minmax(AVL_set *root, int type){
    while(root->child[type] !=NULL)  root= root->child[type];
    return root->val;
}
void AVL_set_inside_swap(AVL_set **node1, AVL_set **node2){
    AVL_set *tmp;  tmp=*node1; *node1=*node2; *node2=tmp;
}

#define set_MAX_SIZE 514511
ll set_main( int command , int set_num , ll val ){
    static bool set_is_init=false;
    static AVL_set *set_pointer[set_MAX_SIZE];
    static ll set_siz[set_MAX_SIZE];
    if(!set_is_init){ set_is_init=true; rep(i,0,set_MAX_SIZE){ *(set_pointer+i) = NULL; set_siz[i]=0; } }
    if(command==-1){ AVL_set_inside_print( set_pointer[set_num] ,0); }
    if(command==1){ AVL_set_inside_count(set_pointer[set_num],val) ? 1 : set_siz[set_num]++;  AVL_set_inside_update( &set_pointer[set_num] , val , 2 ); }
    if(command==2){ return AVL_set_inside_count(set_pointer[set_num],val); }
    if(command==3){ ( AVL_set_inside_count(set_pointer[set_num],val) > 1 ) ? 1 : set_siz[set_num]--;  AVL_set_inside_update( &set_pointer[set_num] , val,1); }
    if(command==4){ set_siz[set_num]--; AVL_set_inside_update( &set_pointer[set_num] , val , 0 ); }
    if(command==5){ set_siz[set_num]=0; AVL_set_inside_free( set_pointer[set_num] ); set_pointer[set_num] = NULL; }
    if(command==6){ return set_siz[set_num]; }
    if(command==7){ return AVL_set_inside_minmax(set_pointer[set_num],1); }
    if(command==8){ return AVL_set_inside_minmax(set_pointer[set_num],0); }
    if(command==9){ AVL_set_inside_swap(&set_pointer[set_num],&set_pointer[val]); }
    return 0;
}

void set_print(int set_num){ set_main(-1,set_num,0); }
void set_insert(int set_num, ll val){ set_main(1,set_num,val); }
ll set_count(int set_num, ll val){ return set_main(2,set_num,val); }
void set_erase(int set_num, ll val, int is_all){ if(is_all) set_main(4,set_num,val); else set_main(3,set_num,val); }
void set_clear(int set_num){ set_main(5,set_num,0); }
ll set_size(int set_num){ return set_main(6,set_num,0); }
ll set_max(int set_num){ return set_main(7,set_num,0); }
ll set_min(int set_num){ return set_main(8,set_num,0); }
void set_swap(ll set_num1, ll set_num2){ set_main(9,set_num1,set_num2); }

/*
insert *
size *
clear *
erase *
count *
max *
min *
swap *
begin
end
merge  source の要素のキーと等価なキーの要素がある場合、その要素は source から抽出されない
lower_bound
upper_bound
*/

// ll map_main()

/*---------------------------AVL start--------------------------------*/

#pragma endregion AVL

#pragma endregion kyopuro_templates

char s[1151154];
// char t[1151154];
ll ans[115115];
void solve(){
    // fgets(s,sizeof(s),stdin);
    ll n;
    // ll ans=0;
    cin(&n);
    scanf("%s",s);
    fr aa[n];
    rep(i,0,n){
        aa[i].a = s[i]-'a';
        aa[i].b=i;
        aa[i].c=-1;
    }
    ll t[n];
    rep(i,0,n){t[i]=aa[i].a;}
    rep(i,0,n){ans[i]=-1;}
    sortup(t,n);
    // rep(i,0,n){printf("%lld",t[i]);}PN;
    rep(i,0,n){
        // rep(i,0,n){
        //     printf("%lld",aa[i].a);
        // }PN;
        if(t[i]!=aa[i].a){
            rep(j,i+1,n){
                if(t[i]==aa[j].a){
                    // printf("%lld %lld\n",i,j);
                    if(aa[i].c==-1){
                        if(aa[j].c==-1){
                            aa[i].c=0;
                            aa[j].c=1;
                        }else{
                            aa[i].c=aa[j].c^1;
                        }
                    }else{
                        if(aa[i].c==aa[j].c){
                            printf("NO\n"); return;
                        }
                        if(aa[j].c==-1){
                            aa[j].c=aa[i].c^1;
                        }
                    }
                    swap_struct(&aa[i],&aa[j]);
                    break;
                    // s[j]=s[i];
                    // s[i]=t[i];
                }
            }
        }else{
            if(aa[i].c==-1){
                aa[i].c=0;
            }
        }
    }
    strsortup(aa,n);
    printf("YES\n");
    rep(i,0,n){
        printf("%lld",aa[i].c);
    }PN;
}

int main(void){
    ll T=1;
    // cin(&T);
    rep(i,0,T){ solve(); }
    return 0;
}

/*
    while (ng + 1 < ok) {
        int p = ng + (ok - ng) / 2;
        int cnt = 0;
        for (i = 0; i < n; i++) {
            cnt += (a[i] + p - 1) / p - 1;
        }
        if (cnt <= k) ok = p; else ng = p;
    }
*/
// 10^18 2^60 3^38 5^26


#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i, j;
	char s[202];
	scanf("%s", s);
	int ans[202];
	int b;
	ans[0] = 0;
	b = 0;
	for (i = 1; i < n; i++)
	{
		if (s[i] >= s[b])
		{
			ans[i] = 0;
			b = i;
		}
		else
		{
			ans[i] = 1;
		}
	}
	b = -1;
	for (i = 0; i < n; i++)
	{
		if (ans[i] > 0)
		{
			if (b < 0)
				b = i;
			else if (s[i] >= s[b])
				b = i;
			else
			{
				printf("NO\n");
				return 0;
			}
		}
	}
	for (i = 0; i < n; i++)
		printf("%d", ans[i]);
	printf("\n");
	return 0;
}


#pragma region kyopuro_templates
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
#include<time.h>
#include<ctype.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<62)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 20)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5
#define PI 3.141592653589793238

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
void cin(ll *n){ scanf("%lld",&(*n)); }
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
double POW_d(double a, double b){double c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }
ll digits(ll a, ll b){return a/b?1+digits(a/b,b):1;}
ll base(ll n, ll a, ll i){return i==1?n%a:base(n/a,a,i-1);}
ll is_inArr1(ll x, ll n){ return ( x<0 || x>=n ) ? 0 : 1 ; }
ll is_inArr2(ll y, ll x, ll h, ll w){ return ( y<0 || y>=h || x<0 || x>=w ) ? 0 : 1 ; }

void lr_lower( int *l, int *r, ll am, ll val , int type ){ (type<3) ? ( am < val ?  ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ) : ( am <= val ? ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ); }
void lr_upper( int *l, int *r, ll am, ll val , int type ){ (type<3) ? ( am <= val ?  ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ) : ( am < val ? ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ); }
int cmp_lower( ll a, ll b, int type ){ return (type==1) ? ( a==b ? 1 : 0 ) : (type==2) ? ( a>=b ? 1 : 0 ) : ( a>b ? 1 : 0 ) ; }
int cmp_upper( ll a, ll b, int type ){ return (type==1) ? ( a==b ? 1 : 0 ) : (type==2) ? ( a<=b ? 1 : 0 ) : ( a<b ? 1 : 0 ) ; }
// return smallest p  which meets  a[p]==val :1  >=:2   >:3
ll lower_bound( ll a[], int l, int r, ll val , int type ){  while(r-l>1) lr_lower(&l,&r,a[ (l+r)/2 ],val,type);  return cmp_lower(a[l],val,type) ? l : cmp_lower(a[r],val,type) ? r : -1;  }
// return biggest p  which meets   a[p]==val :1  <=:2   <:3
ll upper_bound( ll a[], int l, int r, ll val , int type ){  while(r-l>1) lr_upper(&l,&r,a[ (l+r)/2 ],val,type); return cmp_upper(a[r],val,type) ? r : cmp_upper(a[l],val,type) ? l : -1; }
// count i  which meets ai==x
ll count(ll a[], int l, int r, ll x){  int p = lower_bound(a,l,r,x,1);  return p==-1 ? 0 : upper_bound(a,p,r,x,1)-p+1; }

ll *factors[2] , fac_cnt=0 , is_factor_prepared=0;
ll factor_pre(){  rep(i,0,1){ if(is_factor_prepared++) return 0; }  ll tmp=(1e6)/2+1, fac_tmp[tmp];  rep(i,0,tmp){fac_tmp[i]=i?2*i+1:2;}  rep(i,1,tmp){if(fac_tmp[i]){  repp(j,3,tmp/(2*i+1)+1,2 ){  if( j*(2*i+1)<tmp ) fac_tmp[ (j*(2*i+1)-1)/2 ]=0;  }  }else continue;}  rep(i,0,tmp){if(fac_tmp[i]){  rep(j,0,2){ factors[j] = realloc( factors[j] , sizeof(ll)*( fac_cnt +1 ) );  factors[j][j?fac_cnt++:fac_cnt]=j?0:fac_tmp[i];  }  } }  return 0;  }
ll factor(ll n, ll new_common_plus){ factor_pre();  rep(i,0,fac_cnt){ ll cnt=0; rep(j,0,1){ while( ( cnt+= n %factors[0][i]==0 ? 1 : 0 )  && (n/=factors[0][i]) %factors[0][i]==0 ) continue; } factors[1][i]= new_common_plus==1 ? cnt :  new_common_plus==2 ? max2(factors[1][i],cnt) : factors[1][i]+cnt ;  if( factors[0][i]> n ) break; } return n; }
ll judge_prime(ll n){ factor_pre(); rep(i,0,fac_cnt){ if(n<factors[0][i]*factors[0][i] || n==factors[0][i]) break; else if(n%factors[0][i]==0) n/=n; }  return n==1?0:1; }

ll *mf_arr,*inv_arr,*finv_arr,is_minv_made=0,is_mf_made=0,num_of_inv=2*1e6+10;
ll makeinv(ll n , ll mod){  rep(i,0,1){if(is_minv_made++) return 0;}  inv_arr = realloc(inv_arr, sizeof(ll)*2 );  finv_arr = realloc(finv_arr, sizeof(ll)*2 );  inv_arr[1]=1;finv_arr[0]=finv_arr[1]=1;  rep(i,2,n+1){  inv_arr = realloc(inv_arr, sizeof(ll)*(i+1) );  finv_arr = realloc(finv_arr, sizeof(ll)*(i+1) );  inv_arr[i]= mod - inv_arr[mod%i] * (mod / i) % mod;  finv_arr[i] = finv_arr[i - 1] * inv_arr[i] % mod;  }  return 0; }
ll make_mf(ll n, ll mod){  rep(i,0,1){ if(is_mf_made++) return 0; }  mf_arr = realloc(mf_arr, sizeof(ll)*2 );  ll x=1;  mf_arr[0]=mf_arr[1]=x;  rep(i,2,n+1){   x=x*i%mod;  mf_arr = realloc(mf_arr, sizeof(ll)*(i+1) );  mf_arr[i]=x; }  return 0;  }
ll m_inv(ll x, ll mod, ll is_fac ){ makeinv(num_of_inv,mod);  return is_fac?finv_arr[x]:inv_arr[x]; }
ll m_f(ll x, ll mod){  make_mf(num_of_inv,mod);  return mf_arr[x];  }
ll mod_nck(ll n, ll k, ll mod){ return m_f(n,mod)*m_inv(k,mod,1)%mod*m_inv(n-k,mod,1)%mod; }
ll m_p(ll r,ll n,ll mod){  ll t=1,s=r;  while(n>0){ t = (n&1) ? t*s%mod : t;  s=s*s%mod; n>>=1; }  return r?t:0;  }
ll m_mul2(ll a, ll b, ll mod){ return a*b%mod; }
ll m_mul3(ll a, ll b, ll c, ll mod){ return m_mul2(a*b%mod,c,mod); }
ll m_mul4(ll a, ll b, ll c, ll d, ll mod){ return m_mul3(a*b%mod,c,d,mod); }
ll m_mul5(ll a, ll b, ll c, ll d, ll e, ll mod){ return m_mul4(a*b%mod,c,d,e,mod); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
int cmp_string( const void * a , const void * b ) {  return strcmp( (char *)a , (char *)b ); }  // qsort((void*)s,n,sizeof(s[0]),int_sort );
int cmp_char(const void * a, const void * b) { return *(char *)a - *(char *)b;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
void sort_string(int n,int size,char s[][size]){ qsort( (void*)s , n , sizeof(s[0]) , cmp_string ); }
void sort_char(char *s){ qsort( (void *)s , strlen(s) , sizeof(char) , cmp_char ); }
ll unique_string(ll n ,ll size, char s[][size]){ ll ans=1; rep(i,1,n) if( strcmp(s[i],s[i-1]) ) ans++; return ans; }
ll unique_num(ll n , ll a[]){ ll ans=1; rep(i,1,n) if( a[i]!=a[i-1] ) ans++; return ans; }

typedef struct{ ll a , b,c;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->b - ((fr*)q)->b;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}
void swap_struct( fr* p, fr* q ){
    fr r;
    r=*p;
    *p=*q;
    *q=r;
}

#pragma region AVL
/*---------------------------AVL start--------------------------------*/
//https://qiita.com/mikecat_mixc/items/e9f8248de2ae7f7a0a29
typedef struct node_AVL_set{
    ll val;
    int diff;
    int cnt;
    struct node_AVL_set *child[2];
}AVL_set;
void AVL_set_inside_rotate(AVL_set **node, int is_right){
    int l = is_right==false , r = is_right==true , sign = is_right ? 1 : -1;
    if((*node)->child[l] != NULL){
        AVL_set* left = (*node)->child[l];
        int a= (*node)->diff * sign , b= left->diff * sign ,na,nb;
        if(b+1){
            na=a-1-b;
            nb= (a-b) ? b-1 : a-2;
        }else{
            na=a-1;
            nb= a ? b-1 : a+b-2;
        }
        (*node)->diff = na * sign;
        left->diff = nb * sign;
        /* rotate-> */
        (*node)->child[l] = (*node)->child[l]->child[r];
        left->child[r] = *node;
        *node = left;
    }
}
int AVL_set_inside_update(AVL_set **node, ll data, int add){
    if(*node == NULL){
        if(add==2){
            *node = malloc(sizeof(AVL_set));
            (*node)->val = data;
            (*node)->cnt = 1;
            (*node)->diff = 0;
            (*node)->child[0] = NULL;
            (*node)->child[1] = NULL;
        }
        return add==2 ? *node != NULL : 0;
    }else{
        int l, delta, delta_sign; AVL_set *next_node;
        if(data == (*node)->val){
            if(add==2){
                (*node)->cnt++;
                return 0;
            }else{
                if( add && (*node)->cnt > 1 ){
                    (*node)->cnt--; return 0;
                }else{
                    if((*node)->child[1] == NULL){
                        next_node = (*node)->child[0];
                        free(*node);
                        *node = next_node;
                        return -1;
                    }else if((*node)->child[0] == NULL){
                        next_node = (*node)->child[1];
                        free(*node);
                        *node = next_node;
                        return -1;
                    }else{
                        for(next_node = (*node)->child[0];
                        next_node->child[1] != NULL;
                        next_node = next_node->child[1]);
                        (*node)->val = next_node->val;
                        l=0;
                        delta_sign=1;
                        delta = AVL_set_inside_update(&(*node)->child[l], next_node->val, add);
                    }
                }
            }
        }else{
            l = data >= (*node)->val ? 1 : 0;
            delta_sign = data < (*node)->val ? 1 : -1;
            delta = AVL_set_inside_update(&(*node)->child[l], data, add);
        }
        if( delta ){
            int orig_diff = (*node)->diff;
            int do_rotate = 0, rotate_l , diff_sign , rotate_right;
            (*node)->diff += delta * delta_sign;
            if((*node)->diff > 1){
                do_rotate = 1;
                rotate_l = 0;
                diff_sign = 1;
                rotate_right = 1;
            }else if((*node)->diff < -1){
                do_rotate = 1;
                rotate_l = 1;
                diff_sign = -1;
                rotate_right = 0;
            }
            if(do_rotate){
                int child_diff = (*node)->child[rotate_l]->diff;
                if((*node)->child[rotate_l]->diff * diff_sign < 0){
                    AVL_set_inside_rotate(&(*node)->child[rotate_l], !rotate_right);
                }
                AVL_set_inside_rotate(node, rotate_right);
                return delta < 0 && child_diff != 0 ? -1 : 0;
            }
            if     (delta > 0 && orig_diff == 0) return 1;
            else if(delta < 0 && orig_diff != 0) return -1;
            else                                 return 0;
        }else{
            return 0;
        }
    }
}

void AVL_set_inside_print(const AVL_set *node, int depth){
    if(node == NULL) return;
    AVL_set_inside_print(node->child[1], depth + 1);
    printf("%lld %d\n", node->val,node->cnt);
    AVL_set_inside_print(node->child[0], depth + 1);
}
void AVL_set_inside_free(AVL_set *node){
    if(node == NULL) return;
    AVL_set_inside_free(node->child[0]);
    AVL_set_inside_free(node->child[1]);
    free(node);
}
ll AVL_set_inside_count(AVL_set *root, ll val){
    AVL_set *node; node = root;
    while(node){
        if     (val < node->val) node = node->child[0];
        else if(val > node->val) node = node->child[1];
        else                     return node->cnt;
    }
    return 0;
}
ll AVL_set_inside_minmax(AVL_set *root, int type){
    while(root->child[type] !=NULL)  root= root->child[type];
    return root->val;
}
void AVL_set_inside_swap(AVL_set **node1, AVL_set **node2){
    AVL_set *tmp;  tmp=*node1; *node1=*node2; *node2=tmp;
}

#define set_MAX_SIZE 514511
ll set_main( int command , int set_num , ll val ){
    static bool set_is_init=false;
    static AVL_set *set_pointer[set_MAX_SIZE];
    static ll set_siz[set_MAX_SIZE];
    if(!set_is_init){ set_is_init=true; rep(i,0,set_MAX_SIZE){ *(set_pointer+i) = NULL; set_siz[i]=0; } }
    if(command==-1){ AVL_set_inside_print( set_pointer[set_num] ,0); }
    if(command==1){ AVL_set_inside_count(set_pointer[set_num],val) ? 1 : set_siz[set_num]++;  AVL_set_inside_update( &set_pointer[set_num] , val , 2 ); }
    if(command==2){ return AVL_set_inside_count(set_pointer[set_num],val); }
    if(command==3){ ( AVL_set_inside_count(set_pointer[set_num],val) > 1 ) ? 1 : set_siz[set_num]--;  AVL_set_inside_update( &set_pointer[set_num] , val,1); }
    if(command==4){ set_siz[set_num]--; AVL_set_inside_update( &set_pointer[set_num] , val , 0 ); }
    if(command==5){ set_siz[set_num]=0; AVL_set_inside_free( set_pointer[set_num] ); set_pointer[set_num] = NULL; }
    if(command==6){ return set_siz[set_num]; }
    if(command==7){ return AVL_set_inside_minmax(set_pointer[set_num],1); }
    if(command==8){ return AVL_set_inside_minmax(set_pointer[set_num],0); }
    if(command==9){ AVL_set_inside_swap(&set_pointer[set_num],&set_pointer[val]); }
    return 0;
}

void set_print(int set_num){ set_main(-1,set_num,0); }
void set_insert(int set_num, ll val){ set_main(1,set_num,val); }
ll set_count(int set_num, ll val){ return set_main(2,set_num,val); }
void set_erase(int set_num, ll val, int is_all){ if(is_all) set_main(4,set_num,val); else set_main(3,set_num,val); }
void set_clear(int set_num){ set_main(5,set_num,0); }
ll set_size(int set_num){ return set_main(6,set_num,0); }
ll set_max(int set_num){ return set_main(7,set_num,0); }
ll set_min(int set_num){ return set_main(8,set_num,0); }
void set_swap(ll set_num1, ll set_num2){ set_main(9,set_num1,set_num2); }

/*
insert *
size *
clear *
erase *
count *
max *
min *
swap *
begin
end
merge  source の要素のキーと等価なキーの要素がある場合、その要素は source から抽出されない
lower_bound
upper_bound
*/

// ll map_main()

/*---------------------------AVL start--------------------------------*/

#pragma endregion AVL

#pragma endregion kyopuro_templates

char s[1151154];
// char t[1151154];
ll ans[115115];
void solve(){
    // fgets(s,sizeof(s),stdin);
    ll n;
    // ll ans=0;
    cin(&n);
    scanf("%s",s);
    fr aa[n];
    rep(i,0,n){
        aa[i].a = s[i]-'a';
        aa[i].b=i;
        aa[i].c=-1;
    }
    ll t[n];
    rep(i,0,n){t[i]=aa[i].a;}
    rep(i,0,n){ans[i]=-1;}
    sortup(t,n);
    // rep(i,0,n){printf("%lld",t[i]);}PN;
    rep(i,0,n){
        // rep(i,0,n){
        //     printf("%lld",aa[i].a);
        // }PN;
        if(t[i]!=aa[i].a){
            rep(j,i+1,n){
                if(t[i]==aa[j].a){
                    // printf("%lld %lld\n",i,j);
                    if(aa[i].c==-1){
                        if(aa[j].c==-1){
                            aa[i].c=0;
                            aa[j].c=1;
                        }else{
                            aa[i].c=aa[j].c^1;
                        }
                    }else{
                        if(aa[i].c==aa[j].c){
                            printf("NO\n"); return;
                        }
                        if(aa[j].c==-1){
                            aa[j].c=aa[i].c^1;
                        }
                    }
                    swap_struct(&aa[i],&aa[j]);
                    break;
                    // s[j]=s[i];
                    // s[i]=t[i];
                }
            }
        }else{
            if(aa[i].c==-1){
                aa[i].c=0;
            }
        }
    }
    strsortup(aa,n);
    printf("YES\n");
    rep(i,0,n){
        printf("%lld",aa[i].c);
    }
}

int main(void){
    ll T=1;
    // cin(&T);
    rep(i,0,T){ solve(); }
    return 0;
}

/*
    while (ng + 1 < ok) {
        int p = ng + (ok - ng) / 2;
        int cnt = 0;
        for (i = 0; i < n; i++) {
            cnt += (a[i] + p - 1) / p - 1;
        }
        if (cnt <= k) ok = p; else ng = p;
    }
*/
// 10^18 2^60 3^38 5^26


#include <stdio.h>
#include<stdlib.h>
typedef long long lol;

int main()
{
    lol n, M = 998244353;
    scanf("%lld",&n);
    lol arr[n+1],id=2;
    lol pr[1000000];
    pr[0]=2;
    pr[1]=3;
    lol i,j,k,p,ct,i1;
    arr[1]=1;
    for(i=2;i<=n;i++)
    {
        p=0;
        while((p<id) && (i%(pr[p])!=0) && (pr[p]*pr[p]<i)) p++;
        if(p==id)
        {
            arr[i]=2;
            pr[id]=i;
            id++;
            continue;
        }
        p = pr[p];
        ct = 0;
        i1=i;
        while(i1%p==0)
        {
            ct++;
            i1/=p;
        }
        arr[i] = arr[i1]*(ct+1);
    }
    lol ex = 1;
    lol ans = arr[n]%M, a1;
    for(i=1;i<n;i++)
    {
        a1 = (ex*arr[n-i])%M;
        ans+=a1;
        ans%=M;
        ex*=2;
        ex%=M;
    }
    printf("%lld",ans);
    return 0;
}


#include <stdio.h>

#define N	3000
#define M	3000

void slide(int *aa, int *bb, int n, int m) {
	static int qq[N];
	int i, head, cnt;

	head = cnt = 0;
	for (i = 0; i < n; i++) {
		while (cnt && aa[qq[head + cnt - 1]] > aa[i])
			cnt--;
		qq[head + cnt++] = i;
		if (i >= m - 1)
			bb[i - m + 1] = aa[qq[head]];
		if (qq[head] == i - m + 1)
			head++, cnt--;
	}
}

int main() {
	static int aa[N][M], bb[N][M], cc[N], dd[N];
	int n, m, a, b, g, x, y, z, i, j;
	long long ans;

	scanf("%d%d%d%d%d%d%d%d", &n, &m, &a, &b, &g, &x, &y, &z);
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			aa[i][j] = g;
			g = ((long long) g * x + y) % z;
		}
	for (i = 0; i < n; i++)
		slide(aa[i], bb[i], m, b);
	ans = 0;
	for (j = 0; j + b <= m; j++) {
		for (i = 0; i < n; i++)
			cc[i] = bb[i][j];
		slide(cc, dd, n, a);
		for (i = 0; i + a <= n; i++)
			ans += dd[i];
	}
	printf("%lld\n", ans);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int64_t i64;
typedef int32_t i32;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

#define POS(i, j) ((i) * m + (j))

void run (void) {
  i32 n = read_int();
  i32 m = read_int();
  i32 a = read_int();
  i32 b = read_int();
  i32 *h = ALLOC (n * m, i32);
  h[0] = read_int();
  i32 x = read_int();
  i32 y = read_int();
  i32 z = read_int();
  for (i32 i = 1; i < n * m; ++i) {
    h[i] = ((i64) h[i - 1] * x + y) % z;
  }
  i32 *dp1 = ALLOC (n * m, i32);
  i32 *q = ALLOC (n + m, i32);
  for (i32 i = 0; i < n; ++i) {
    i32 front = 0;
    i32 last = 0;
    q[last++] = 0;
    for (i32 j = 1; j < b; ++j) {
      while (front < last && h[POS(i, q[last - 1])] >= h[POS(i, j)]) --last;
      q[last++] = j;
    }
    dp1[POS(i, 0)] = h[POS(i, q[front])];
    for (i32 j = b; j < m; ++j) {
      if (q[front] == j - b) front++;
      while (front < last && h[POS(i, q[last - 1])] >= h[POS(i, j)]) --last;
      q[last++] = j;
      dp1[POS(i, j - b + 1)] = h[POS(i, q[front])];
    }
  }
  {
    i32 *swap = dp1;
    dp1 = h;
    h = swap;
  }
  i64 ans = 0;
  for (i32 j = 0; j < m - b + 1; ++j) {
    i32 front = 0;
    i32 last = 0;
    q[last++] = 0;
    for (i32 i = 1; i < a; ++i) {
      while (front < last && h[POS(q[last - 1], j)] >= h[POS(i, j)]) --last;
      q[last++] = i;
    }
    ans += h[POS(q[front], j)];
    for (i32 i = a; i < n; ++i) {
      if (q[front] == i - a) front++;
      while (front < last && h[POS(q[last - 1], j)] >= h[POS(i, j)]) --last;
      q[last++] = i;
      ans += h[POS(q[front], j)];
    }
  }
  print_int (ans);
  puts ("");
}

int main (void) {
  run ();
  return 0;
}


#include<stdio.h>
#include<string.h>

int table[2][3000][3000];
long long g, x, y, z;
#define MAXINT 0x7fffffff

int nextg(){
	int ret=g;
	g=(g*x+y)%z;
	return ret;
}

int min(int a, int b){
	return a<b?a:b;
}

int msb(int a){
	a|=a>>1;
	a|=a>>2;
	a|=a>>4;
	a|=a>>8;
	a|=a>>16;
	return (a+1)>>1;
}

int main(){
	int i, j, k, n, m, a, b, tren, prev, l;
	long long sum=0;
	scanf("%d %d %d %d %lld %lld %lld %lld", &n, &m, &a, &b, &g, &x, &y, &z);
	for(i=0;i<n;++i)
		for(j=0;j<m;++j)
			table[0][i][j]=nextg();
	for(k=0;(1<<(k+1))<=a;++k){
		prev=k&1;
		tren=!prev;
		for(i=0;i<n-(1<<k);++i){
			for(j=0;j<m;++j){
				table[tren][i][j]=min(table[prev][i][j], table[prev][i+(1<<k)][j]);
			}
		}
	}
	for(l=0;(1<<(l+1))<=b;++l){
		prev=(l+k)&1;
		tren=!prev;
		for(i=0;i<n-(1<<k);++i){
			for(j=0;j<m-(1<<l);++j){
				table[tren][i][j]=min(table[prev][i][j], table[prev][i][j+(1<<l)]);
			}
		}
	}
	for(i=0;i+a<=n;++i){
		for(j=0;j+b<=m;++j){
			sum+=(long long)(min(min(min(
								table[tren][i][j],
								table[tren][i+a-msb(a)][j]),
								table[tren][i][j+b-msb(b)]),
								table[tren][i+a-msb(a)][j+b-msb(b)]));
		}
	}
	printf("%I64d\n", sum);
	return 0;
}


#include<stdio.h>
#include<string.h>

int tree[8000][8000], node;
long long g, x, y, z;
#define MAXINT 0x7fffffff

int nextg(){
	int ret=g;
	g=(g*x+y)%z;
	return ret;
}

int min(int a, int b){
	return a<b?a:b;
}

void build1(int n, int l, int r, int l2, int r2){
	if(l+1==r){
		if(l2+1==r2){
			tree[node][n]=nextg();
		}
		else{
			tree[node][n]=min(tree[2*node+1][n], tree[2*node+2][n]);
		}
		return;
	}
	int m=(l+r)/2;
	build1(2*n+1, l, m, l2, r2);
	build1(2*n+2, m, r, l2, r2);
	tree[node][n]=min(tree[node][2*n+1], tree[node][2*n+2]);
}

void build2(int n, int l, int r, int rd){
	if(l+1==r){
		node=n;
		build1(0, 0, rd, l, r);
		return;
	}
	int m=(l+r)/2;
	build2(2*n+1, l, m, rd);
	build2(2*n+2, m, r, rd);
	node=n;
	build1(0, 0, rd, l, r);
}

int query1(int n, int l, int r, int ql, int qr){
	if(qr<=l || r<=ql) return MAXINT;
	if(ql<=l && r<=qr){
		return tree[node][n];
	}
	int m=(l+r)/2;
	return min(query1(2*n+1, l, m, ql, qr),
			query1(2*n+2, m, r, ql, qr));
}

int query2(int n, int l, int r, int r2, int ql, int qr, int ql2, int qr2){
	if(qr<=l || r<=ql) return MAXINT;
	if(ql<=l && r<=qr){
		node=n;
		return query1(0, 0, r2, ql2, qr2);
	}
	int m=(l+r)/2;
	return min(query2(2*n+1, l, m, r2, ql, qr, ql2, qr2),
			query2(2*n+2, m, r, r2, ql, qr, ql2, qr2));
}

int main(){
	memset(tree, 0x7f, sizeof(tree));
	int i, j, n, m, a, b;
	long long sum=0;
	scanf("%d %d %d %d %I64d %I64d %I64d %I64d", &n, &m, &a, &b, &g, &x, &y, &z);
	build2(0, 0, n, m);
	for(i=0;i+a<=n;++i){
		for(j=0;j+b<=m;++j){
			sum+=(long long)query2(0, 0, n, m, i, i+a, j, j+b);
		}
	}
	printf("%I64d\n", sum);
	return 0;
}


#include<stdio.h>
#include<string.h>

int tree[3*3000][3*3000], node;
long long g, x, y, z;
#define MAXINT 0x7fffffff

int nextg(){
	int ret=g;
	g=(g*x+y)%z;
	return ret;
}

int min(int a, int b){
	return a<b?a:b;
}

void build1(int n, int l, int r, int l2, int r2){
	if(l+1==r){
		if(l2+1==r2){
			tree[node][n]=nextg();
		}
		else{
			tree[node][n]=min(tree[2*node+1][n], tree[2*node+2][n]);
		}
		return;
	}
	int m=(l+r)/2;
	build1(2*n+1, l, m, l2, r2);
	build1(2*n+2, m, r, l2, r2);
	tree[node][n]=min(tree[node][2*n+1], tree[node][2*n+2]);
}

void build2(int n, int l, int r, int rd){
	if(l+1==r){
		node=n;
		build1(0, 0, rd, l, r);
		return;
	}
	int m=(l+r)/2;
	build2(2*n+1, l, m, rd);
	build2(2*n+2, m, r, rd);
	node=n;
	build1(0, 0, rd, l, r);
}

int query1(int n, int l, int r, int ql, int qr){
	if(qr<=l || r<=ql) return MAXINT;
	if(ql<=l && r<=qr){
		return tree[node][n];
	}
	int m=(l+r)/2;
	return min(query1(2*n+1, l, m, ql, qr),
			query1(2*n+2, m, r, ql, qr));
}

int query2(int n, int l, int r, int r2, int ql, int qr, int ql2, int qr2){
	if(qr<=l || r<=ql) return MAXINT;
	if(ql<=l && r<=qr){
		node=n;
		return query1(0, 0, r2, ql2, qr2);
	}
	int m=(l+r)/2;
	return min(query2(2*n+1, l, m, r2, ql, qr, ql2, qr2),
			query2(2*n+2, m, r, r2, ql, qr, ql2, qr2));
}

int main(){
	memset(tree, 0x7f, sizeof(tree));
	int i, j, n, m, a, b;
	long long sum=0;
	scanf("%d %d %d %d %I64d %I64d %I64d %I64d", &n, &m, &a, &b, &g, &x, &y, &z);
	build2(0, 0, n, m);
	for(i=0;i+a<=n;++i){
		for(j=0;j+b<=m;++j){
			sum+=(long long)query2(0, 0, n, m, i, i+a, j, j+b);
		}
	}
	printf("%I64d\n", sum);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<memory.h>
#include<assert.h>
#include<ctype.h>

typedef long long ll;

#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(k) (((k)>0)?(k):(-(k)))
int modint(int a,int b) {return(((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1)));}
ll modll(ll a,ll b) {return(((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1)));}
#define mod(a,b) a=modint(a,b)
#define llmod(a,b) a=modll(a,b)
#define mset(a) memset(a,0,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define inf (1e9)
#define linf (1e18)
#define pi 3.14159265358979323846

void fileio_in_out()
{
     freopen(".in","r",stdin);
     freopen(".out","w",stdout);
}

void fileio_txt()
{
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
}

//==================================================

#define modnum (inf+9)

int n,h,x,y,z,ww,xx,yy,zz;
int i,j,k,l;
ll dp[33][33][33][2][2],ans=0,t;

int main()
{
    //fileio_in_out();
    //fileio_txt();

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

    mset(dp);
    dp[0][0][0][0][1]=1;
    for(k=0;k<n;k++)
      for(x=0;x<=h;x++)
        for(y=0;y<=h;y++)
          for(z=0;z<=h;z++)
            for(j=0;j<=1;j++)
              {
                i=k%2;
                t=dp[x][y][z][i][j];
                llmod(t,modnum);
                dp[x][y][z][i][j]=0;

                i^=1;
                xx=min(x+1,h);
                yy=min(y+1,h);
                zz=min(z+1,h);
                ww=j?1:h;

                dp[xx][yy][zz][i][j]+=t;
                dp[yy][zz][ww][i][(x<h)]+=t;
                dp[xx][zz][ww][i][(y<h)]+=t;
                dp[xx][yy][ww][i][(z<h)]+=t;
              }

    i=n%2;
    for(x=0;x<=h;x++)
      for(y=0;y<=h;y++)
        for(z=0;z<=h;z++)
          for(j=0;j<=1;j++)
            if(x<h||y<h||z<h||j)
              {
                ans+=dp[x][y][z][i][j];
                llmod(ans,modnum);
              }

    printf("%I64d\n",ans);

    //system("pause");
    return 0;
}


#define __USE_MINGW_ANSI_STDIO 0
#include <stdio.h>

// MODULAR NCR
// DEPENDENCIES:

// nCr % mod function
// Using Fermat's Little theorem: a^(p-2) = a^(-1) (mod p)

#define maxN 200000
#define MOD 1000000007
//#define MOD 998244353

// Build factorial array
long long fac[maxN + 1];
void __attribute__((constructor))
initFacs() {
	fac[0] = 1;
    for (int i = 1; i <= maxN; i++) fac[i] = fac[i - 1] * i % MOD;
}

// Calculate base ^ pow % mod
long long mPow(long long base, int pow) {
    long long res = 1;
    base %= MOD;
    // constantly decompose base ^ pow = (base ^ 2) ^ (pow / 2)
    while (pow > 0) {
        // make sure if it is odd, then base ^ pow = base ^ (pow - 1) * base
        if (pow % 2 == 1) res = res * base % MOD;
        pow /= 2;
        base = (base * base) % MOD;
    }
    return res;
}

// a ^ (p - 2) = a ^ (-1) (mod p)
long long mInv(long long n) {
    return mPow(n, MOD - 2);
}

// nCr = n! / r! / (n - r)!
// nCr = n! * inv(r!) * inv((n - r)!)
long long mnCr(long long n, int r) {
    // Base cases
    if (n < r) return 0;
    if (r == 0) return 1;

    return fac[n] * mInv(fac[r]) % MOD
           * mInv(fac[n - r]) % MOD;
}
// END MODULAR NCR

long long _T[maxN + 1];
long long _2n[maxN + 1];

void testcase() {
	int n, k;
	scanf("%d%d", &n, &k);
	long long T;
	long long ans;
	if (n % 2 == 1) {
		// n odd
		T = 1;
		for (int i = 0; i <= (n - 1) / 2; ++i) {
			T += mnCr(n, i);
			T %= MOD;
		}
		ans = 1;
		for (int i = 0; i < k; ++i) {
			ans *= T;
			ans %= MOD;
		}
	} else {
		// n even
		T = 0;
		for (int i = 0; i < n; i += 2) {
			T += mnCr(n, i);
			T %= MOD;
		}
		_T[0] = 1;
		long long base = mPow(2, n);
		_2n[0] = 1;
		for (int i = 1; i <= k; ++i) {
			_T[i] = _T[i - 1] * T % MOD;
			_2n[i] = _2n[i - 1] * base % MOD;
		}
		ans = _T[k] * _2n[0] % MOD;
		for (int i = k - 1; i >= 0; --i) {
			ans += _T[i] * _2n[k - 1 - i] % MOD;
			ans %= MOD;
		}
	}
	printf("%lld\n", ans);
    return;
}

int main() {
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; ++i) testcase();
    return 0;
}


#include <stdio.h>
#include <ctype.h>

// Program de Mircea Rebengiuc
// inceput pe 2021.08.09

#define MOD 1000000007
#define MAXN 200000
#define MAXK 200000

int p2[MAXK + 1];

static inline int multmod( int a, int b ){
  return (((long long)a) * b) % MOD;
}

static inline int addmod( int a, int b ){
  return (a + b) % MOD;
}

// chestii invmod
static inline int myExp( int a, int n ){
  int acc = 1;

  while( n > 0 ){
    if( n & 1 )
      acc = multmod(acc, a);
    a = multmod(a, a);
    n >>= 1;
  }

  return acc;
}

static inline int inv( int x ){
  return myExp(x, MOD - 2);
}

int main(){
  int t, n, k, i, big_num, comb, numeq, answer;

  p2[0] = 1;
  for( i = 1 ; i <= MAXK ; i++ )
    p2[i] = multmod(2, p2[i - 1]);

  for( scanf("%d", &t) ; t-- ; ){
    scanf("%d%d", &n, &k);

    // calculam big_num = numarul de moduri de a face o pozitie sa fie egala (and = xor) modificand doar bitii de pe acea pozitie
    // cazul and = xor = 1
    big_num = (n & 1);

    // cazul and = xor = 0
    comb = 1;
    for( i = 0 ; i < n ; i += 2 ){
      big_num = addmod(big_num, comb);
      comb = multmod(comb, multmod(n - i, n - i - 1));
      comb = multmod(comb, multmod(inv(i + 1), inv(i + 2)));
    }

    // simulam
    numeq = 1;// numeq = numarul de moduri de a face primele i cifre egale modificand doar primele i cifre
    answer = 0;
    for( i = 0 ; i < k ; i++ ){
      if( (n & 1) == 0 )// cazul in care pentru bitul i and = 1, xor = 0
        answer = addmod(answer, multmod(numeq, myExp(p2[k - i - 1], n)));// adaugam numarul de posibilitati

      numeq = multmod(numeq, big_num);// actualizam x
    }
    answer = addmod(answer, numeq);// adaugam numarul de cazuri in care e egal ca semnul este >=

    printf("%d\n", answer);
  }

  return 0;
}


#include <stdio.h>
#define int long long
int n,k,a,x,y,T,M=1e9+7;
int power(int p,int z)
{
	if(z==0) return 1%M;
	if(z==1) return p%M;
	int tt=power(p,z/2);
	if(z&1) return ((tt*tt)%M)*p%M;
	else return (tt*tt)%M;
}
main()
{
	scanf("%lld",&T);
	while(T--)
	{
		scanf("%lld%lld",&n,&k);
		if(n&1)
		{
			y=(power(2,n-1)+1)%M;
			y=power(y,k);
		}
		else
		{
			y=power(2,n-1);
			x=(power(2,n-1)-1+M)%M;
			a=((y*power(x,k))%M+power((2*y)%M,k)+M)%M;
			a=a*power((y+1)%M,M-2)%M;
			y=a;
		}
		printf("%lld\n",y);
	}
}


#include <stdio.h>

#define MD	1000000007

long long power(long long a, int k) {
	long long p = 1;

	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int main() {
	int t;

	scanf("%d", &t);
	while (t--) {
		int n, k, i, ans;

		scanf("%d%d", &n, &k);
		if (k == 0)
			printf("1\n");
		else if (n % 2 == 1)
			printf("%lld\n", power(power(2, n - 1) + 1, k));
		else {
			ans = power(power(2, n - 1) - 1, k);
			for (i = 0; i < k; i++)
				ans = (ans + power(power(2, n - 1) - 1, i) * power(power(2, n), k - 1 - i)) % MD;
			printf("%d\n", ans);
		}
	}
	return 0;
}


#include <stdio.h>
#include <ctype.h>

// Program de Mircea Rebengiuc
// inceput pe 2021.08.09

#define MOD 1000000007
#define MAXN 100000
#define MAXK 100000

int p2[MAXK + 1];

static inline int multmod( int a, int b ){
  return (((long long)a) * b) % MOD;
}

static inline int addmod( int a, int b ){
  return (a + b) % MOD;
}

// chestii invmod
static inline int myExp( int a, int n ){
  int acc = 1;

  while( n > 0 ){
    if( n & 1 )
      acc = multmod(acc, a);
    a = multmod(a, a);
    n /= 2;
  }

  return acc;
}

static inline int inv( int x ){
  return myExp(x, MOD - 2);
}

int main(){
  int t, n, k, i, big_num, comb, x, answer;

  p2[0] = 1;
  for( i = 1 ; i <= MAXK ; i++ )
    p2[i] = (2 * p2[i - 1]) % MOD;// nu tb sa fac long long ca nu 2 * MOD nu da overflow

  for( scanf("%d", &t) ; t-- ; ){
    scanf("%d%d", &n, &k);

    // calculam big_num
    big_num = 0;
    comb = 1;
    for( i = 0 ; i < n ; i += 2 ){
      big_num = addmod(big_num, comb);
      comb = multmod(comb, multmod(n - i, n - i - 1));
      comb = multmod(comb, multmod(inv(i + 1), inv(i + 2)));
    }

    // simulam
    x = 1;
    answer = 0;// scadem din total ca conditia este >=
    for( i = 0 ; i < k ; i++ ){
      answer = addmod(answer, (1 ^ (n & 1)) * multmod(x, p2[k - i - 1])) % MOD;
      x = multmod(x, (n & 1) + big_num);
    }
    answer = addmod(answer, x);

    printf("%d\n", answer);
  }

  return 0;
}


#include <stdio.h>

#define N	123456
#define K	60
#define MD	1000000007

int main() {
	static int dp[K][6];
	int k, n, h, c, ans;

	scanf("%d", &k), n = 0;
	for (c = 0; c < 6; c++)
		dp[0][c] = 1;
	for (h = 1; h < k; h++) {
		int sum = 0;

		for (c = 0; c < 6; c++)
			sum = (sum + dp[h - 1][c]) % MD;
		for (c = 0; c < 6; c++)
			dp[h][c] = ((long long) sum - dp[h - 1][c] - dp[h - 1][c ^ 1]) % MD * ((long long) sum - dp[h - 1][c] - dp[h - 1][c ^ 1]) % MD;
	}
	ans = 0;
	for (c = 0; c < 6; c++)
		ans = (ans + dp[k - 1][c]) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>

long long unsigned int n, ans, modulo;

void solve(){
    scanf("%llu", &n);

    /* if(n == 1){ */
    /*     puts("6"); */
    /*     return; */
    /* } */

    ans = 1;
    n--;
    while(n--){
        ans = ans * 4;
        ans = ans % modulo;
        ans = ans * ans;
        ans = ans % modulo;
    }

    ans = ans * 6;
    ans = ans % modulo;

    printf("%llu\n", ans);
}

int main(){
    modulo = 1000000007;
    solve();
}


#include <stdio.h>
#define MOD 1000000007
char str[500005];

int pow(int base, long long fac)
{
    int ret = 1;
    while(fac)
    {
        if (fac & 1)
            ret = 1ll * ret * base % MOD;
        base = 1ll * base * base % MOD;
        fac >>= 1;
    }
    return ret;
}

int main(void)
{
    int k;
    scanf("%d", &k);
    int ans = 6ll * pow(4, (1ll << k) - 2) % MOD;
    printf("%d", ans);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

#define MOD_NUMBER 1000000007

unsigned long long modpow(int n, unsigned long long index) {
    unsigned long long nn = n;
    unsigned long long ans = 1;
    while (index) {
        if (index & 1) {
            ans *= nn;
            ans %= MOD_NUMBER;
        }
        nn *= nn;
        nn %= MOD_NUMBER;
        index >>= 1;
    }

    return ans;
}

int run() {
    int n;
    scanf("%d", &n);
    long long a = (6*modpow(4, (1<<n) - 2))%MOD_NUMBER;
    printf("%lld\n", a);
    return 0;
}

int main(int argc, char* argv[]) {
    int n = 1;
    for (int i = 0; i < n; ++i) {
        run();
    }
    return 0;
}


#pragma c11 on

#include<stdio.h>
#include<stdbool.h>
#include<limits.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define MOD (int)(1e9+7)
typedef enum colorType{
    white, green, red, blue, orange ,yellow
}colorType;

typedef struct treeNode{
    colorType color;
    struct treeNode* previous;
    struct treeNode* next;
}treeNode;
typedef struct tree{
    treeNode * root;
    int size;
}tree;
void makePerfectTree(int *t,int*k,treeNode* node){
    if(*t<*k){
        node->previous=calloc(1,sizeof(treeNode));
        node->next=calloc(1,sizeof(treeNode));
        (*t)++;
        makePerfectTree(t,k,node->previous);
        makePerfectTree(t,k,node->next);
    }
}

long long quickPow(long long n, long long powers) {
    long long res = 1;
    while (powers > 0) {
        if (powers & 1)
            res =res * n%MOD;
        n = n*n%MOD;
        powers >>= 1;
    }
    return res;
}
int main(void){
    int k;
    scanf("%d",&k);
    /*tree * tree1=(tree*)calloc(1,sizeof(tree));
    tree1->root=calloc(1,sizeof(treeNode));
    int t=1;
    makePerfectTree(&t,&k,tree1->root);
    //forget the idiot tree;
*/
    printf("%lld",6* quickPow(4, ((1<<k)-2))%MOD);
    return 0;
}


#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <ctype.h>
#include <math.h>
#include <stdbool.h>

#define DEBUG
typedef int (*cmp_t) (const void *, const void *);
typedef unsigned uint;
typedef long long int64;
typedef unsigned long long uint64;
#define max(i, j) ({int _ = (i), __ = (j); _ > __ ? _ : __;})
#define min(i, j) ({int _ = (i), __ = (j); _ < __ ? _ : __;})
#define swap(T, i, j) ({T _ = (i); (i) = (j); (j) = _;})
#ifdef DEBUG
#define cerr(...) fprintf (stderr, __VA_ARGS__)
void disp (char *s, int *x, int n) {int i; cerr ("[%s: ", s); for (i = 0; i < n - 1; ++i) cerr ("%d ", x[i]); if (n) cerr ("%d", x[i]); cerr ("]\n");}
#else
#define cerr(...) ({})
#define disp(...) ({})
#endif
#define CR cerr ("\n")
#ifdef WIN32
#define fmt64 "%I64d"
#else
#define fmt64 "%lld"
#endif

#define maxm 1100
#define maxsz 125

const int mod = 12345;
typedef int mat[maxsz][maxsz];

int qx[maxm], qc[maxm];
int sz = 0;
bool o[30][maxsz];
mat u, v;
int prod[30], val[30];

int fpm (int b, int64 e, int m)
{
  int t = 1;
  for (; e; e >>= 1, b = b * b % m)
    e & 1 ? t = b * t % m : 0;
  return t;
}

int gcd (int a, int b)
{
  int t;
  for (; a; t = a, a = b % a, b = t);
  return b;
}

void matmul (mat a, mat b, mat c)
{
  mat t; int i, j, k;
  for (i = 0; i < sz; ++i)
    for (j = 0; j < sz; ++j)
      for (k = 0, t[i][j] = 0; k < sz; ++k)
        t[i][j] += a[i][k] * b[k][j] % mod;
  for (i = 0; i < sz; ++i)
    for (j = 0; j < sz; ++j)
      c[i][j] = t[i][j] % mod;
}

int main ()
{
#ifndef ONLINE_JUDGE
  freopen ("107D.in" , "r", stdin);
  freopen ("107D.out", "w", stdout);
#endif

  int64 n; int m, i, j, x, c; char C;

  scanf (fmt64 "%d", &n, &m);
  for (i = 0; i < 26; ++i)
    val[i] = -1;
  for (i = 1; i <= m; ++i)
    {
      scanf (" %c%d", &C, &x), c = C - 'A';
      qc[i] = c, qx[i] = x, val[c] = abs (val[c] * x / gcd (x, val[c]));
    }
  for (i = 1; i <= m; ++i)
    for (x = 0; x < val[qc[i]]; x += qx[i])
      o[qc[i]][x] = true;
  for (i = 1, prod[0] = 1; i < 26; ++i)
    prod[i] = prod[i - 1] * abs (val[i - 1]);
  /* disp ("prod", prod, 26); */
  /* disp ("val", val, 26); */

  sz = prod[26] = prod[25] * abs (val[25]);
  for (i = 0; i < sz; ++i)
    for (j = 0; j < 26; ++j)
      if (val[j] != -1)
        {
          x = i + prod[j];
          if (x % prod[j + 1] < prod[j])
            x -= prod[j + 1];
          ++u[i][x];
        }
  /* for (i = 0; i < sz; ++i) */
  /*   disp ("u", u[i], sz); */

  v[0][0] = 1;
  for (; n; n >>= 1, matmul (u, u, u))
    n & 1 ? matmul (v, u, v) : 0;

  /* for (i = 0; i < sz; ++i) */
  /*   disp ("u", v[i], sz); */
  /* for (i = 0; i < 26; ++i) */
  /*   { */
  /*     for (j = 0; j < val[i]; ++j) */
  /*       cerr ("%d ", o[i][j]); */
  /*     CR; */
  /*   } */
  int ans = 0;
  for (i = 0; i < sz; ++i)
    {
      bool b = true;
      for (j = 0; j < 26; ++j)
        if (val[j] != -1 && !o[j][i % prod[j + 1] / prod[j]])
          b = false;
      if (b) ans += v[0][i];
    }
  printf ("%d\n", ans % mod);
  return 0;
}


#include <stdio.h>
/*thanks  to rainboy,danger :)*/
int main() {
	long long u, v, w;

	scanf("%lld%lld", &u, &v);
	if (u > v || (v - u) % 2 != 0) {
		printf("-1\n");
		return 0;
	}
	if (u == 0 && v == 0) {
		printf("0\n");
		return 0;
	}
	if (u == v) {
		printf("1\n");
		printf("%lld\n", u);
		return 0;
	}
	w = (v - u) / 2;
	if ((u & w) == 0) {
		printf("2\n");
		printf("%lld %lld\n", w, u ^ w);
		return 0;
	}
	printf("3\n");
	printf("%lld %lld %lld\n", u, w, w);
	return 0;
}


#include <stdio.h>

int main(){
	long long u, v, c, s;
	long long a[60];
	int i, j = 0;
	scanf("%lld%lld", &u, &v);
	/*c = 1;
 	while(u / c > 0){
		if((u & c) == c){
			a[j++] = c;
		}
		c = c << 1;
	}
	if(v < u){
		printf("-1\n", -1);
		return 0;
	}
	printf("%lld\n", v - u + j);
	for(i = 0; i < v - u; i++){
		printf("1 ");
	}
	for(i = 0; i < j; i++){
		printf("%lld ", a[i]);
	}
	printf("\n");*/
	s = (v - u) / 2;
	if(u > v || (v - u) % 2 == 1){
		printf("-1\n");
	}
	else if(u == v){
		if(u == 0 || v == 0)
			printf("0\n");
		else{
			printf("1\n");
			printf("%lld", u);
		}
	}
	else if((u & s) == 0){
		printf("2\n");
		printf("%lld %lld\n", u + s, s);
	}
	else{
		printf("3\n");
		printf("%lld %lld %lld\n", u, s, s);
	}
	return 0;
}


#include<stdio.h>
int main()
{
	long long int u, v;
	scanf("%lld %lld", &u, &v);
	if (u > v)
	{
		printf("-1\n");
		return 0;
	}
	if ((v - u) % 2 > 0)
	{
		printf("-1\n");
		return 0;
	}
	if (v == 0)
	{
		printf("0\n");
		return 0;
	}
	if (u == v)
	{
		printf("1\n%lld\n", u);
		return 0;
	}
	if ((u ^ ((v - u) / 2)) == u + (v - u) / 2)
		printf("2\n%lld %lld\n", u ^ (v - u) / 2, (v - u) / 2);
	else
		printf("3\n%lld %lld %lld\n", u, (v - u) / 2, (v - u) / 2);
	return 0;
}


#include<stdio.h>
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        if(n>m)
        {
            printf("-1\n");
            continue;
        }
        else if(n==m)
        {
            printf("%d\n",n);
            continue;
        }
        else
        {
            if((m-n)%2!=0)
                printf("-1\n");
            else
            printf("%d %d %d\n",n,(m-n)/2,(m-n)/2);
        }
    }
    return 0;
}