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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        int arr[5] = {0,0,0,0,0};
        scanf("%d",&n);
        int i = 0;
        int j = 0;
        while(n > 0)
        {
            arr[i] = (n%10)*pow(10,j);
            i++;
            j++;
            n = n/10;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%d",arr[k]);
            }
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        int arr[5] = {0};
        scanf("%d",&n);
        int j = 0;
        while(n > 0)
        {
            arr[j] = n%10 ;
            j++;
            n = n/10;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%.0lf ",arr[k]*pow(10,k));
            }
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        float arr[5] = {0};
        scanf("%d",&n);
        int j = 0;
        while(n > 0)
        {
            arr[j] = (n%10)*pow(10,j);
            j++;
            n = n/10;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%.0f ",arr[k]);
            }
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        float arr[5] = {0};
        scanf("%d",&n);
        int j = 0;
        while(n > 0)
        {
            arr[j] = (n%10);
            j++;
            n = n/10;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%.0lf ",arr[k]*pow(10,k));
            }
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        int arr[5] = {0};
        scanf("%d",&n);
        int j = 0;
        while(n > 0)
        {
            arr[j] = (n%10)*pow(10,j);
            j++;
            n = n/10;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%d ",arr[k]);
            }
        }
        printf("\n");
    }
    return 0;


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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        int arr[5] = {0};
        scanf("%d",&n);
        int i = 0;
        int j = 0;
        while(n > 0)
        {
            arr[i] = (n%10)*pow(10,j);
            i++;
            j++;
            n = n/10;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%d",arr[k]);
            }
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        int arr[5] = {0,0,0,0,0};
        scanf("%d",&n);
        int i = 0;
        int j = 0;
        while(n > 0)
        {
            arr[i] = (n%10)*pow(10,j);
            i++;
            j++;
            n = n/10;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%d",&arr[k]);
            }
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        int arr[5];
        scanf("%d",&n);
        int i = 0;
        int j = 0;
        while(n > 0)
        {
            arr[i] = (n%10)*pow(10,j);
            i++;
            j++;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%d",&arr[k]);
            }
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        int arr[5] = {0};
        scanf("%d",&n);
        int j = 0;
        while(n > 0)
        {
            arr[j] = (n%10)*pow(10,j);
            j++;
            n = n/10;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%d ",arr[k]);
            }
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        int arr[5] = {0};
        scanf("%d",&n);
        int j = 0;
        while(n > 0)
        {
            arr[j] = (n%10)*pow(10,j);
            j++;
            n = n/10;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%d ",arr[k]*pow(10,k));
            }
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        int arr[5] = {0};
        scanf("%d",&n);
        int j = 0;
        while(n > 0)
        {
            arr[j] = (n%10);
            j++;
            n = n/10;
        }
        int count = 0;
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                count++;
            }
        }
        printf("%d\n",count);
        for(int k=0;k<5;k++)
        {
            if(arr[k] != 0)
            {
                printf("%.0lf ",arr[k]*pow(10,k));
            }
        }
        printf("\n");
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
        int t;
        scanf("%d",&t);
        for(int i=0;i<t;i++)
        {
                int n,k=1;
                scanf("%d",&n);
                printf("%d\n",(int)floor(log(n)/log(10))+1);
                while(n!=0)
                {
                        int rem = n%10;
                        if(rem!=0)
                        printf("%d ",rem*k);
                        k*=10;
                        n/=10;
                }
                printf("\n");
        }
        return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
        int t;
        scanf("%d",&t);
        for(int i=0;i<t;i++)
        {
                int n,k=1,*a,j=0,count=0;
                scanf("%d",&n);
		a=(int*)calloc(n,sizeof(int));
                while(n!=0)
                {
                        int rem = n%10;
                        if(rem!=0)
                        a[j++]=rem*k,
			a[j]=-1,
			count++;
                        k*=10;
			n/=10;
                }
		printf("%d\n",count);
		for(int l=0;a[l]!=-1;l++)
		printf("%d ",a[l]);
                printf("\n");
		free(a);
        }
        return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
        int t;
        scanf("%d",&t);
        for(int i=0;i<t;i++)
        {
                int n,k=1;
                scanf("%d",&n);
                while(n!=0)
                {
                        int rem = n%10;
                        if(rem!=0)
                        printf("%d ",rem*k);
                        k*=10;
                        n/=10;
                }
                printf("\n");
        }
        return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
        int t;
        scanf("%d",&t);
        for(int i=0;i<t;i++)
        {
                int n,k=1;
                scanf("%d",&n);
                printf("%d\n",floor(log(n)/log(10))+1);
                while(n!=0)
                {
                        int rem = n%10;
                        if(rem!=0)
                        printf("%d ",rem*k);
                        k*=10;
                        n/=10;
                }
                printf("\n");
        }
        return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main()
{
        int t;
        scanf("%d",&t);
        for(int i=0;i<t;i++)
        {
                int n,k=1;
                scanf("%d",&n);
                printf("%d\n",floor(log(n)/log(10))+1);
                while(n!=0)
                {
                        int rem = n%10;
                        if(rem!=0)
                        printf("%d ",rem*k);
                        k*=10;
                        n/=10;
                }
                printf("\n");
        }
        return 0;
}


/*
 *        File: main.c
 * Description: Codeforce problemset 1352A - Sum of Round Numbers.
 *  Created on: Aug 11 2020 08:10 +0700
 *      Author: tbtt
 */
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

#define MAX_LEN 4

int
main (void)
{
#ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
#endif
  uint16_t t;
  uint16_t n;
  uint16_t rounds[MAX_LEN];
  uint8_t nRound;
  uint16_t unit;
  uint16_t tenPow;
  uint8_t i;
  scanf ("%" SCNu16, &t);
  while (t--)
    {
      scanf ("%" SCNu16, &n);
      nRound = 0;
      tenPow = 1;
      while (n)
        {
          unit = n % 10;
          if (unit)
            {
              rounds[nRound++] = unit * tenPow;
            }
          n /= 10;
          tenPow *= 10;
        }
      printf ("%" PRIu8 "\n", nRound);
      for (i = 0; i < nRound; ++i)
        {
          printf ("%" PRIu16 " ", rounds[i]);
        }
      printf ("\n");
    }
  return EXIT_SUCCESS;
}


/*
 *        File: main.c
 * Description: Codeforce problemset 1352A - Sum of Round Numbers.
 *  Created on: Aug 11 2020 08:10 +0700
 *      Author: tbtt
 */
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

#define MAX_LEN 4

int
main (void)
{
#ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
#endif
  uint8_t t;
  uint16_t n;
  uint16_t rounds[MAX_LEN];
  uint8_t nRound;
  uint16_t unit;
  uint16_t tenPow;
  uint8_t i;
  scanf ("%" SCNu8, &t);
  while (t--)
    {
      scanf ("%" SCNu16, &n);
      i = 0;
      tenPow = 1;
      while (n)
        {
          unit = n % 10;
          if (unit)
            {
              rounds[i++] = unit * tenPow;
            }
          n /= 10;
          tenPow *= 10;
        }
      nRound = i;
      printf ("%" PRIu8 "\n", nRound);
      for (i = 0; i < nRound; ++i)
        {
          printf ("%" PRIu16 " ", rounds[i]);
        }
      printf ("\n");
    }
  return EXIT_SUCCESS;
}


/*
 *        File: main.c
 * Description: Codeforce problemset 1352A - Sum of Round Numbers.
 *  Created on: Aug 11 2020 08:10 +0700
 *      Author: tbtt
 */
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

#define MAX_LEN 4

int
main (void)
{
#ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
#endif
  uint16_t t;
  uint16_t n;
  uint16_t rounds[MAX_LEN];
  uint8_t nRound;
  uint16_t unit;
  uint16_t tenPow;
  uint8_t i;
  scanf ("%" SCNu16, &t);
  while (t--)
    {
      scanf ("%" SCNu16, &n);
      i = 0;
      tenPow = 1;
      while (n)
        {
          unit = n % 10;
          if (unit)
            {
              rounds[i++] = unit * tenPow;
            }
          n /= 10;
          tenPow *= 10;
        }
      nRound = i;
      printf ("%" PRIu8 "\n", nRound);
      for (i = 0; i < nRound; ++i)
        {
          printf ("%" PRIu16 " ", rounds[i]);
        }
      printf ("\n");
    }
  return EXIT_SUCCESS;
}


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

int main()
{

    int i,t,n,temp,count,d;
    scanf("%d",&t);
    while(t--)
    {
      count=0;
      scanf("%d",&n);
      temp=n;
      while(temp!=0)
      {
          d=temp%10;
          temp=temp/10;
          if(d!=0)
            count++;
      }
      printf("%d\n",count);
      i=-1;
      while(n!=0)
      {
        i++;
        d=n%10;
        n=n/10;
        if(d!=0)
          printf("%d ",d*pow(10,i));
      }
      printf("\n");
    }
    return 0;
}


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

int main()
{

    int i,t,n,temp,count,d;
    scanf("%d",&t);
    while(t--)
    {
      count=0;
      scanf("%d",&n);
      temp=n;
      while(temp!=0)
      {
          d=temp%10;
          temp=temp/10;
          if(d!=0)
            count++;
      }
      printf("%d\n",count);
      i=-1;
      while(n!=0)
      {
        i++;
        d=n%10;
        n=n/10;
        if(d!=0)
          printf("%.0lf ",d*pow(10,i));
      }
      printf("\n");
    }
    return 0;
}


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

int main()
{

    int i,t,n,temp,count,d;
    scanf("%d",&t);
    while(t--)
    {
      count=0;
      scanf("%d",&n);
      temp=n;
      while(temp!=0)
      {
          d=temp%10;
          temp=temp/10;
          if(d!=0)
            count++;
      }
      printf("%d\n",count);
      i=-1;
      while(n!=0)
      {
        i++;
        d=n%10;
        n=n/10;
        if(d!=0)
          printf("%.0f ",d*pow(10,i));
      }
      printf("\n");
    }
    return 0;
}


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

int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		int n, n_tmp, c = 0, tmp, c_tmp = 0;
		scanf("%d", &n);
		n_tmp = n;
		while (n_tmp) {
			tmp = n_tmp % 10;
			n_tmp /= 10;
			if (tmp) {
				c++;
			}
		}
		printf("%d\n", c);
		while (n) {
			tmp = n % 10;
			n /= 10;
			if (tmp) {
				printf("%d", tmp);
				for (int i = 0; i < c_tmp; i++) {
					printf("0");
				}
				printf(" ");
			}
			c_tmp++;
		}
		printf("\n");
	}
	return 0;
}


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

int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		int n, n_tmp, c = 0, tmp, c_tmp = 0;
		scanf("%d", &n);
		n_tmp = n;
		while (n_tmp) {
			tmp = n_tmp % 10;
			n_tmp /= 10;
			if (tmp) {
				c++;
			}
		}
		printf("%d\n", c);
		int test = 1;
		while (n) {
			tmp = n % 10;
			n /= 10;
			if (tmp) {
				printf("%d", tmp);
				for (int i = 0; i < c_tmp; i++) {
					printf("0");
				}
				if (test < c) {
					printf(" ");
					test += 1;
				}
			}
			c_tmp++;
		}
		printf("\n");
	}
	return 0;
}


#include <stdio.h>

double pow(double a,double b){
    double r=1;
    for(int i=0;i<b;i++){
        r*=a;
    }
    return r;
}

int main() {
	int cnt,number;
	scanf("%d", &cnt);
	int arr[7];
	for (int i = 0; i < cnt; i++) {
		int t = 0;
		scanf("%d", &number);
		if (number % 10 != 0) {
			arr[0] = number % 10;
			number -= number % 10;
			t++;
		}
		int j = 1;
		do{
			j++;
			if (number % (int)pow(10, j) != 0) {
				arr[t] = (number % (int)pow(10, j));
				number -= number % (int)pow(10, j);
				t++;
			}
		} while (number / (int)pow(10, j) != 0);
		printf("%d\n", t);
		for (int j = 0; j < t; j++)	printf("%d ", arr[j]);
      	printf("\n");
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int cnt, number;
	scanf("%d", &cnt);
	int arr[7];
	for (int i = 0; i < cnt; i++) {
		int t = 0;
		scanf("%d", &number);
		if (number % 10 != 0) {
			arr[0] = number % 10;
			number -= number % 10;
			t++;
		}
		int j = 1;
		int nuer = 1;
		do {
			j++;
			nuer *= 10;
			if (number % nuer != 0) {
				arr[t] = (number % nuer);
				number -= number % nuer;
				t++;
			}
		} while (number / nuer != 0);
		printf("%d\n", t);
		for (int j = 0; j < t; j++)	printf("%d ", arr[j]);
		printf("\n");
	}
	return 0;
}


#include <stdio.h>

int pow(a,b){
    for(int i=0;i<b;i++){
        a*=a;
    }
    return a;
}

int main() {
	int cnt,number;
	scanf("%d", &cnt);
	int arr[7];
	for (int i = 0; i < cnt; i++) {
		int t = 0;
		scanf("%d", &number);
		if (number % 10 != 0) {
			arr[0] = number % 10;
			number -= number % 10;
			t++;
		}
		int j = 1;
		do{
			j++;
			if (number % (int)pow(10, j) != 0) {
				arr[t] = (number % (int)pow(10, j));
				number -= number % (int)pow(10, j);
				t++;
			}
		} while (number / (int)pow(10, j) != 0);
		printf("%d\n", t);
		for (int j = 0; j < t; j++)	printf("%d ", arr[j]);
      	printf("\n");
	}
	return 0;
}


#include <stdio.h>

double pow(double a,double b){
    for(int i=0;i<b;i++){
        a*=a;
    }
    return a;
}

int main() {
	int cnt,number;
	scanf("%d", &cnt);
	int arr[7];
	for (int i = 0; i < cnt; i++) {
		int t = 0;
		scanf("%d", &number);
		if (number % 10 != 0) {
			arr[0] = number % 10;
			number -= number % 10;
			t++;
		}
		int j = 1;
		do{
			j++;
			if (number % (int)pow(10, j) != 0) {
				arr[t] = (number % (int)pow(10, j));
				number -= number % (int)pow(10, j);
				t++;
			}
		} while (number / (int)pow(10, j) != 0);
		printf("%d\n", t);
		for (int j = 0; j < t; j++)	printf("%d ", arr[j]);
      	printf("\n");
	}
	return 0;
}


#include <stdio.h>

double pow(double a,double b){
    double r=1
    for(int i=0;i<b;i++){
        r*=a;
    }
    return r;
}

int main() {
	int cnt,number;
	scanf("%d", &cnt);
	int arr[7];
	for (int i = 0; i < cnt; i++) {
		int t = 0;
		scanf("%d", &number);
		if (number % 10 != 0) {
			arr[0] = number % 10;
			number -= number % 10;
			t++;
		}
		int j = 1;
		do{
			j++;
			if (number % (int)pow(10, j) != 0) {
				arr[t] = (number % (int)pow(10, j));
				number -= number % (int)pow(10, j);
				t++;
			}
		} while (number / (int)pow(10, j) != 0);
		printf("%d\n", t);
		for (int j = 0; j < t; j++)	printf("%d ", arr[j]);
      	printf("\n");
	}
	return 0;
}


#include <stdio.h>
double pow(double a,double b){
    double r=1;
    for(int i=0;i<b;i++){
        r*=a;
    }
    return r;
}
int main() {
   int n;

   scanf("%d", &n);
   for (int i = 0; i < n; i++) {
      char num[6] = {0};
      scanf("%s", num);
      if (strlen(num) == 1) {
         printf("1\n%s\n", num);
      }
      else {
         int len = strlen(num);
         int result[10000] = { 0 };
         int cnt = 0;
         for (int j = 0; j < len; j++) {
            if (num[j] == '0') {
               continue;
            }
            else {
               char tmp = num[j];
               result[cnt] = atoi(&tmp)*pow(10, len - 1 - j);
               //printf("\n%lf\n", pow(10,len-1-j));
               cnt++;
            }
         }
         printf("%d\n", cnt);
         for (int j = cnt-1; j >= 0; j--) {
         //   if (j == 0) {
         //      printf("%d\n", result[j]);
         //   }
         //   else {
               printf("%d ", result[j]);
         //   }
         }
      }
   }
   return 0;
}


#include <stdio.h>

double pow(a,b){
    for(int i=0;i<b;i++){
        a*=a;
    }
    return a;
}

int main() {
	int cnt,number;
	scanf("%d", &cnt);
	int arr[7];
	for (int i = 0; i < cnt; i++) {
		int t = 0;
		scanf("%d", &number);
		if (number % 10 != 0) {
			arr[0] = number % 10;
			number -= number % 10;
			t++;
		}
		int j = 1;
		do{
			j++;
			if (number % (int)pow(10, j) != 0) {
				arr[t] = (number % (int)pow(10, j));
				number -= number % (int)pow(10, j);
				t++;
			}
		} while (number / (int)pow(10, j) != 0);
		printf("%d\n", t);
		for (int j = 0; j < t; j++)	printf("%d ", arr[j]);
      	printf("\n");
	}
	return 0;
}


#include <stdio.h>
#include <math.h>
int main() {
   int n;

   scanf("%d", &n);
   for (int i = 0; i < n; i++) {
      char num[6] = {0};
      scanf("%s", num);
      if (strlen(num) == 1) {
         printf("1\n%s\n", num);
      }
      else {
         int len = strlen(num);
         int result[10000] = { 0 };
         int cnt = 0;
         for (int j = 0; j < len; j++) {
            if (num[j] == '0') {
               continue;
            }
            else {
               char tmp = num[j];
               result[cnt] = atoi(&tmp)*pow(10, len - 1 - j);
               //printf("\n%lf\n", pow(10,len-1-j));
               cnt++;
            }
         }
         printf("%d\n", cnt);
         for (int j = cnt-1; j >= 0; j--) {
         //   if (j == 0) {
         //      printf("%d\n", result[j]);
         //   }
         //   else {
               printf("%d ", result[j]);
         //   }
         }
      }
   }
   return 0;
}


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

int main() {
	int cnt,number;
	scanf("%d", &cnt);
	int arr[7];
	for (int i = 0; i < cnt; i++) {
		int t = 0;
		scanf("%d", &number);
		if (number % 10 != 0) {
			arr[0] = number % 10;
			number -= number % 10;
			t++;
		}
		int j = 1;
		do{
			j++;
			if (number % (int)pow(10, j) != 0) {
				arr[t] = (number % (int)pow(10, j));
				number -= number % (int)pow(10, j);
				t++;
			}
		} while (number / (int)pow(10, j) != 0);
		printf("%d\n", t);
		for (int j = 0; j < t; j++)	printf("%d ", arr[j]);
      	printf("\n");
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
	long int t;
	scanf("%ld",&t);
	while(t--)
	{
		long int n,k;
		scanf("%ld",&n);
		long int c=0;
		k=n;
		while(n>0)
		{
			n=n/10;
			c++;
		}
		long int x=0,a[c],i=0;
		while(k>0)
		{
			a[i]=k%10;
			k=k/10;
			i++;
		}
		for(i=0;i<c;i++)
		{
			if(a[i]!=0)
			x++;
		}
		printf("%ld\n",x);
		for(i=0;i<c;i++)
		{
			if(a[i]!=0)
			{
				a[i]=a[i]*pow(10,i);
				printf("%ld ",a[i]);
			}

		}
		printf("\n");
	}
}


#include<stdio.h>
int main ()
{
    int t,dig[4],n,a,count,i,flag;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        flag=0;
        for(a=1,count=0;a<n;a=a*10)
        {
             dig[count]=(n%(a*10))-(n%a);
             if(dig[count]!=0)
                 {
                     count++;
                     flag=1;
                 }
        }
        if(flag==1)
        {
        printf("%d\n",count);
        for(i=0;i<count;i++)
            printf("%d ",dig[i]);
        }
        else if(flag==0)
            printf("1\n%d",n);
    }
}


#include<stdio.h>
int main ()
{
    int t,dig[4],n,a,count,i,flag;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        flag=0;
        for(a=1,count=0;a<n;a=a*10)
        {
             dig[count]=(n%(a*10))-(n%a);
             if(dig[count]!=0)
                 {
                     count++;
                     flag=1;
                 }
        }
        if(flag==1)
        {
        printf("%d\n",count);
        for(i=0;i<count;i++)
            printf("%d ",dig[i]);
        printf("\n");
        }
        else if(flag==0)
            printf("1\n%d\n",n);
    }
}


#include <stdio.h>
#include <math.h>
int main() {
	int t;
	scanf("%d",&t);
	while(t--)
	{
	     int n;
	    scanf("%d",&n);
	    int i=0;
	    int a[4];
	    int co=0;
	    for(int j=n;j>0;j/=10)
	    {
	        int c=(j%10)*(int)pow(10,i);
	        i++;
	        if(c>0)
	        {
	            a[co++]=c;
	        }

	    }
	    printf("%d\n",co);
	    for(int k=0;k<co;k++)
	    {
	        printf("%d ",a[k]);
	    }
	    printf("\n");
}

	return 0;
}


#include <stdio.h>
int po(int i)
{
    int c=1;
    while(i>0)
    {
        c=c*10;
        i--;
    }
    return c;
}
int main() {
	int t;
	scanf("%d",&t);
	while(t--)
	{
	     int n;
	    scanf("%d",&n);
	    int i=0;
	    int a[4];
	    int co=0;
	    for(int j=n;j>0;j/=10)
	    {
	        int c=(j%10)*(int)po(i);
	        i++;
	        if(c>0)
	        {
	            a[co++]=c;
	        }

	    }
	    printf("%d\n",co);
	    for(int j=0;j<co;j++)
	    {
	        printf("%d ",a[j]);
	    }
	    printf("\n");
}

	return 0;
}


#include <stdio.h>
#include <math.h>
int main() {
	int t;
	scanf("%d",&t);
	while(t--)
	{
	     int n;
	    scanf("%d",&n);
	    int i=0;
	    int a[4];
	    int co=0;
	    for(int j=n;j>0;j/=10)
	    {
	        int c=(j%10)*(int)pow(10,i);
	        i++;
	        if(c>0)
	        {
	            a[co++]=c;
	        }

	    }
	    printf("%d\n",co);
	    for(int j=0;j<co;j++)
	    {
	        printf("%d ",a[j]);
	    }
	    printf("\n");
}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
    int t,i,p;
    scanf("%d",&t);
    for(p=1;p<=t;p++){
        int x,sum=0,j,digit[8]={0};
        scanf("%d",&x);
        for(j=1;;j++){
                if(x==0)
                break;
            int temp;
            temp=x%10;
            if(temp!=0)
                sum++;
            digit[j]=temp;
            x=x/10;
        }
        j--;//表示位数
        printf("%d\n",sum);
        int k=0;
        for(i=1;i<=j;i++){
            if(digit[i]!=0){
                double y;
                int u;
                if(k==0){
                    y=pow(10.0,i-1);
                    u=y*digit[i];

                    printf("%d",u);
                }
                else{
                    y=pow(10.0,i-1);
                    u=y*digit[i];

                    printf(" %d",u);
                }
                k++;
            }
        }
        printf("\n");

    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
    int t,i,p;
    scanf("%d",&t);
    for(p=1;p<=t;p++){
        int x,sum=0,j,digit[8]={0};
        scanf("%d",&x);
        for(j=1;;j++){
                if(x==0)
                break;
            int temp;
            temp=x%10;
            if(temp!=0)
                sum++;
            digit[j]=temp;
            x=x/10;
        }
        j--;//表示位数
        printf("%d\n",sum);
        int k=0;
        for(i=1;i<=j;i++){
            if(digit[i]!=0){
                if(k==0)
                    printf("%.0lf",digit[i]*pow(10.0,i-1));
                else{
                    printf(" %.0lf",digit[i]*pow(10,i-1));
                }
                k++;
            }
        }
        printf("\n");

    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
    int t,i,p;
    scanf("%d",&t);
    for(p=1;p<=t;p++){
        int x,sum=0,j,digit[8]={0};
        scanf("%d",&x);
        for(j=1;;j++){
                if(x==0)
                break;
            int temp;
            temp=x%10;
            if(temp!=0)
                sum++;
            digit[j]=temp;
            x=x/10;
        }
        j--;//表示位数
        printf("%d\n",sum);
        int k=0;
        for(i=1;i<=j;i++){
            if(digit[i]!=0){
                int u;
                if(k==0){
                    switch(i){
                        case 1:u=1;
                        break;
                        case 2:u=10;
                        break;
                        case 3:u=100;
                        break;
                        case 4:u=1000;
                        break;
                        case 5:u=10000;
                        break;
                        case 6:u=100000;
                        break;
                    }

                    printf("%d",u*digit[i]);
                }
                else{
                    switch(i){
                        case 1:u=1;
                        break;
                        case 2:u=10;
                        break;
                        case 3:u=100;
                        break;
                        case 4:u=1000;
                        break;
                        case 5:u=10000;
                        break;
                        case 6:u=100000;
                        break;
                    }

                    printf(" %d",u*digit[i]);
                }
                k++;
            }
        }
        printf("\n");

    }
    return 0;
}


#include <stdio.h>

int main(){

    int loop_number, provided_number, array_step, decimals;
    int mat[5];

    scanf("%d", &loop_number);
    while(loop_number>0){

        decimals = 1;
        array_step=0;

        scanf("%d", &provided_number);

        while(decimals <= provided_number){
            decimals *= 10;
            // printf("Decimals: %d; Number:%d\n", decimals, provided_number);
            if(decimals >= provided_number){
                mat[array_step] = provided_number;
                array_step++;
                break;
            }else if(provided_number%decimals!=0){
                mat[array_step] = provided_number%decimals;
                provided_number-=mat[array_step];
                array_step++;
            }
        }

        printf("%d\n", array_step);
        for(int i=0; i<array_step; i++){
            printf("%d ", mat[i]);
        }
        printf("\n");
        loop_number--;
    }

    return 0;
}


#include <stdio.h>

int main(){

    int loop_number, provided_number, array_step, decimals;
    int mat[5];

    scanf("%d", &loop_number);
    while(loop_number>0){

        decimals = 1;
        array_step=0;

        scanf("%d", &provided_number);

        while(decimals < provided_number){
            decimals *= 10;
            if(provided_number%decimals!=0){
                mat[array_step] = provided_number%decimals;
                provided_number-=mat[array_step];
                array_step++;
            }else if(decimals >= provided_number){
                mat[array_step] = provided_number;
                array_step++;
            }
        }

        printf("%d\n", array_step);
        for(int i=0; i<array_step; i++){
            printf("%d ", mat[i]);
        }
        printf("\n");
        loop_number--;
    }

    return 0;
}


#include <stdio.h>

int main(){

    int loop_number, provided_number, array_step, decimals;
    int mat[5];

    scanf("%d", &loop_number);
    while(loop_number>0){

        decimals = 1;
        array_step=0;

        scanf("%d", &provided_number);

        while(decimals <= provided_number){
            decimals *= 10;
            // printf("Decimals: %d; Number:%d\n", decimals, provided_number);
            if(decimals >= provided_number){
                mat[array_step] = provided_number;
                array_step++;
            }else if(provided_number%decimals!=0){
                mat[array_step] = provided_number%decimals;
                provided_number-=mat[array_step];
                array_step++;
            }
        }

        printf("%d\n", array_step);
        for(int i=0; i<array_step; i++){
            printf("%d ", mat[i]);
        }
        printf("\n");
        loop_number--;
    }

    return 0;
}


#include<ctype.h>
#include<limits.h>
#include<float.h>
#include<math.h>
#include<stdbool.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define min(x, y) ((x<=y) ? x : y)
#define max(x, y) ((x<=y) ? y : x)
#define loop(a, b, c) for(ll int a = b; a < c; a++)
#define loop_(a, b, c) for(ll int a = b; a >= c; a--)
#define mod1 1000069
#define mod2 1000000007
#define mod3 1000000009
#define mod4 998244353

void solve();
ll modulo(ll a, ll n, ll p);
ll mod_inverse(ll a, ll p);
ll ncr_modp(ll n, ll r, ll p);
ll gcd(ll  b, ll a);
ll lcm(ll  b, ll a);
ll cmp(const void* x, const void* y);
ll binarySearch(ll arr[], ll l, ll r, ll x);

int main(void){
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif

	long t;
	scanf(" %ld", &t);

	while(t--){
		solve();
	}

	return 0;
}

ll modulo(ll a, ll n, ll p){
	ll ret = 1;
	while(n){
		if(n & 1){
			ret *= a;
			ret %= p;
		}

		n >>= 1;
		a *= a;
		a %= p;
	}

	return ret;
}

ll mod_inverse(ll a, ll p){
	return modulo(a, (p - 2), p);
}

ll ncr_modp(ll n, ll r, ll p){
	if (r == 0){
		return 1;
	}

	ll fac[n + 1];
	fac[0] = 1;

	for(ll i = 1; i <= n; i++){
		fac[i] = (fac[i - 1] * i) % p;
	}

	return (fac[n] * (mod_inverse(fac[r], p) % p) * (mod_inverse(fac[n - r], p) % p)) % p;
}

ll gcd(ll  b, ll a){
	if(a < b){
		return gcd(a, b);
	}

	if(a % b == 0){
		return b;
	}

	return gcd(a % b , b);
}

ll lcm(ll  b, ll a){
	return ((a * b)/gcd(a, b));
}

ll cmp(const void* x, const void* y){
    ll *xx, *yy;
    ll res;
    xx = (ll *)x;
    yy = (ll *)y;
    res = *xx - *yy;
    return(res);
}

ll binarySearch(ll arr[], ll l, ll r, ll x){
	while (l <= r){
		ll m = l + (r - l) / 2;

		if(arr[m] == x){
			return m;
		}

		if(arr[m] < x){
			l = m + 1;
		}

		else{
			r = m - 1;
		}
	}

	return -1;
}

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

	int digits[5];
	digits[0] = n%10;
	digits[1] = (n%100 - digits[0]) / 10;
	digits[2] = (n%1000 - 10*digits[1] - digits[0]) / 100;
	digits[3] = (n%10000 - 100*digits[2] - 10*digits[1] - digits[0]) / 1000;
	digits[4] = (n%100000 - 1000*digits[3] - 100*digits[2] - 10*digits[1] - digits[0]) / 10000;

	loop(i, 0, 5){
		if((digits[i] != 0) && (i == 0)){
			printf("%d ", digits[i]*1);
		}

		if((digits[i] != 0) && (i == 1)){
			printf("%d ", digits[i]*10);
		}

		if((digits[i] != 0) && (i == 2)){
			printf("%d ", digits[i]*100);
		}

		if((digits[i] != 0) && (i == 3)){
			printf("%d ", digits[i]*1000);
		}

		if((digits[i] != 0) && (i == 4)){
			printf("%d ", digits[i]*10000);
		}
	}

	printf("\n");
}


#include<ctype.h>
#include<limits.h>
#include<float.h>
#include<math.h>
#include<stdbool.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define min(x, y) ((x<=y) ? x : y)
#define max(x, y) ((x<=y) ? y : x)
#define loop(a, b, c) for(ll int a = b; a < c; a++)
#define loop_(a, b, c) for(ll int a = b; a >= c; a--)
#define mod1 1000069
#define mod2 1000000007
#define mod3 1000000009
#define mod4 998244353

void solve();
ll modulo(ll a, ll n, ll p);
ll mod_inverse(ll a, ll p);
ll ncr_modp(ll n, ll r, ll p);
ll gcd(ll  b, ll a);
ll lcm(ll  b, ll a);
ll cmp(const void* x, const void* y);
ll binarySearch(ll arr[], ll l, ll r, ll x);

int main(void){
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif

	long t;
	scanf(" %ld", &t);

	while(t--){
		solve();
	}

	return 0;
}

ll modulo(ll a, ll n, ll p){
	ll ret = 1;
	while(n){
		if(n & 1){
			ret *= a;
			ret %= p;
		}

		n >>= 1;
		a *= a;
		a %= p;
	}

	return ret;
}

ll mod_inverse(ll a, ll p){
	return modulo(a, (p - 2), p);
}

ll ncr_modp(ll n, ll r, ll p){
	if (r == 0){
		return 1;
	}

	ll fac[n + 1];
	fac[0] = 1;

	for(ll i = 1; i <= n; i++){
		fac[i] = (fac[i - 1] * i) % p;
	}

	return (fac[n] * (mod_inverse(fac[r], p) % p) * (mod_inverse(fac[n - r], p) % p)) % p;
}

ll gcd(ll  b, ll a){
	if(a < b){
		return gcd(a, b);
	}

	if(a % b == 0){
		return b;
	}

	return gcd(a % b , b);
}

ll lcm(ll  b, ll a){
	return ((a * b)/gcd(a, b));
}

ll cmp(const void* x, const void* y){
    ll *xx, *yy;
    ll res;
    xx = (ll *)x;
    yy = (ll *)y;
    res = *xx - *yy;
    return(res);
}

ll binarySearch(ll arr[], ll l, ll r, ll x){
	while (l <= r){
		ll m = l + (r - l) / 2;

		if(arr[m] == x){
			return m;
		}

		if(arr[m] < x){
			l = m + 1;
		}

		else{
			r = m - 1;
		}
	}

	return -1;
}

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

	ll digits[5];
	digits[0] = n%10;
	digits[1] = (n%100 - digits[0]) / 10;
	digits[2] = (n%1000 - 10*digits[1] - digits[0]) / 100;
	digits[3] = (n%10000 - 100*digits[2] - 10*digits[1] - digits[0]) / 1000;
	digits[4] = (n%100000 - 1000*digits[3] - 100*digits[2] - 10*digits[1] - digits[0]) / 10000;

	loop(i, 0, 5){
		if((digits[i] != 0) && (i == 0)){
			printf("%lld ", digits[i]*1);
		}

		if((digits[i] != 0) && (i == 1)){
			printf("%lld ", digits[i]*10);
		}

		if((digits[i] != 0) && (i == 2)){
			printf("%lld ", digits[i]*100);
		}

		if((digits[i] != 0) && (i == 3)){
			printf("%lld ", digits[i]*1000);
		}

		if((digits[i] != 0) && (i == 4)){
			printf("%lld ", digits[i]*10000);
		}
	}

	printf("\n");
}


#include<ctype.h>
#include<limits.h>
#include<float.h>
#include<math.h>
#include<stdbool.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define min(x, y) ((x<=y) ? x : y)
#define max(x, y) ((x<=y) ? y : x)
#define loop(a, b, c) for(ll int a = b; a < c; a++)
#define loop_(a, b, c) for(ll int a = b; a >= c; a--)
#define mod1 1000069
#define mod2 1000000007
#define mod3 1000000009
#define mod4 998244353

void solve();
ll modulo(ll a, ll n, ll p);
ll mod_inverse(ll a, ll p);
ll ncr_modp(ll n, ll r, ll p);
ll gcd(ll  b, ll a);
ll lcm(ll  b, ll a);
ll cmp(const void* x, const void* y);
ll binarySearch(ll arr[], ll l, ll r, ll x);

int main(void){
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif

	long t;
	scanf(" %ld", &t);

	while(t--){
		solve();
	}

	return 0;
}

ll modulo(ll a, ll n, ll p){
	ll ret = 1;
	while(n){
		if(n & 1){
			ret *= a;
			ret %= p;
		}

		n >>= 1;
		a *= a;
		a %= p;
	}

	return ret;
}

ll mod_inverse(ll a, ll p){
	return modulo(a, (p - 2), p);
}

ll ncr_modp(ll n, ll r, ll p){
	if (r == 0){
		return 1;
	}

	ll fac[n + 1];
	fac[0] = 1;

	for(ll i = 1; i <= n; i++){
		fac[i] = (fac[i - 1] * i) % p;
	}

	return (fac[n] * (mod_inverse(fac[r], p) % p) * (mod_inverse(fac[n - r], p) % p)) % p;
}

ll gcd(ll  b, ll a){
	if(a < b){
		return gcd(a, b);
	}

	if(a % b == 0){
		return b;
	}

	return gcd(a % b , b);
}

ll lcm(ll  b, ll a){
	return ((a * b)/gcd(a, b));
}

ll cmp(const void* x, const void* y){
    ll *xx, *yy;
    ll res;
    xx = (ll *)x;
    yy = (ll *)y;
    res = *xx - *yy;
    return(res);
}

ll binarySearch(ll arr[], ll l, ll r, ll x){
	while (l <= r){
		ll m = l + (r - l) / 2;

		if(arr[m] == x){
			return m;
		}

		if(arr[m] < x){
			l = m + 1;
		}

		else{
			r = m - 1;
		}
	}

	return -1;
}

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

	int digits[5];
	digits[0] = n%10;
	digits[1] = (n%100 - digits[0]) / 10;
	digits[2] = (n%1000 - 10*digits[1] - digits[0]) / 100;
	digits[3] = (n%10000 - 100*digits[2] - 10*digits[1] - digits[0]) / 1000;
	digits[4] = (n%100000 - 1000*digits[3] - 100*digits[2] - 10*digits[1] - digits[0]) / 10000;

	int count = 0;
	loop(i, 0, 5){
		if(digits[i] != 0){
			count++;
		}
	}

	printf("%d\n", count);

	loop(i, 0, 5){
		if((digits[i] != 0) && (i == 0)){
			printf("%d ", digits[i]*1);
		}

		if((digits[i] != 0) && (i == 1)){
			printf("%d ", digits[i]*10);
		}

		if((digits[i] != 0) && (i == 2)){
			printf("%d ", digits[i]*100);
		}

		if((digits[i] != 0) && (i == 3)){
			printf("%d ", digits[i]*1000);
		}

		if((digits[i] != 0) && (i == 4)){
			printf("%d ", digits[i]*10000);
		}
	}

	printf("\n");
}


#include<stdio.h>
#include<math.h>
int p(int x,int y)
{
    int z=1;
    if(y==0)
    return 1;
    if(y==1)
    return x;
    else
    {
        while(y--)
        {
            z=z*x;
        }
        return z;
    }

}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,count=0,arr[5],i=0;
        scanf("%d",&n);
        if(n%10)
        {
            while(n>0)
            {
                count++;
                arr[i]=n%10;
                n=n/10;
                i++;
            }
            int j;
            printf("%d\n",count);
            for(j=0;j<i;j++)
            printf("%d ",p(10,i)*arr[i]);
        }
        else
        {
            int j=0;
            while(n>0)
            {
                if(!(n%10))
                {
                    i++;
                    n=n/10;
                }
                else
                {
                    count++;
                    arr[j]=p(10,i)*n%10;
                    i++;
                    n=n/10;
                    j++;
                }
            }
            printf("%d\n",count);
            while(j>=0)
            printf("%d ",arr[j]);
        }
        printf("\n");
    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        if(!(n%10))
        {
            printf("1");
            printf("%d",n);
        }
        int i=0;
        while(n>0)
        {
            printf("%d",pow(10,i)*n%10);
            n=n/10;
            i++;
        }
    }
}


#include<stdio.h>
int pw(int x,int y)
{
    int z=1;
    if(y==1)
    return x;
    if(y==0)
    return 1;
    else
    {
        while(y--)
        z=z*x;
    }
    return z;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,arr[5],i,count=0;
        scanf("%d",&n);
        i=0;
        while(n)
        {
            arr[i]=n%10;
            i++;
            n=n/10;
        }
        int j;
        for(j=0;j<i;j++)
        {
            if(arr[j])
            {
                arr[j]=pw(10,j)*arr[j];
                count++;
            }
        }
        printf("%d\n",count);
        for(j=0;j<i;j++)
        {
            if(arr[j])
            printf("%d ",arr[j]);
        }
        printf("\n");
    }
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,count=0,arr[5],i=0;
        scanf("%d",&n);
        if(n%10)
        {
            while(n>0)
            {
                count++;
                arr[i]=n%10;
                n=n/10;
                i++;
            }
            int j;
            printf("%d\n",count);
            for(j=0;j<i;j++)
            printf("%d ",pow(10,i)*arr[i]);
        }
        else
        {
            int j=0;
            while(n>0)
            {
                if(!(n%10))
                {
                    i++;
                    n=n/10;
                }
                else
                {
                    count++;
                    arr[j]=pow(10,i)*n%10;
                    i++;
                    n=n/10;
                    j++;
                }
            }
            printf("%d\n",count);
            while(j>=0)
            printf("%d ",arr[j]);
        }
        printf("\n");
    }
}


#include<stdio.h>
int pw(int x,int y)
{
    int z=1;
    if(y==1)
    return x;
    if(y==0)
    return 1;
    else
    {
        while(y--)
        z=z*x;
    }
    return z;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,arr[5],i,count=0;
        scanf("%d",&n);
        i=0;
        while(n)
        {
            arr[i]=n%10;
            i++;
            n=n/10;
        }
        int j;
        for(j=0;j<i;j++)
        {
            if(arr[j])
            {
                arr[j]=pw(10,j)*arr[j];
                count++;
            }
        }
        printf("%d\n",count);
        for(j=0;j<i;j++)
        {
            if(arr[j])
            printf("%d",arr[j]);
        }
        printf("\n");
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
 int x,k;
 int z;
 int u=1;
 int y=10;
 int arr[5];
 int sum=0;
 scanf("%d",&x);
 for(int i=0;i<x;i++)
 {

  scanf("%d",&z);
  if (z<=10 && u==1)
  {
   printf("1\n");
   printf("%d\n",z);
  }
  else
  {
    for(int n=0;n<5;n++)
  {
   arr[n]=0;
  }
  for(int j=0;j<5;j++) {
   if (z%10!=0)
   {
    sum++;
    arr[j]=((z%10)*u);

   }
   u=u*10;
   z=z/(y);
  }
  printf("%d\n",sum);
  for(int o=0;o<5;o++)
  {
   if(arr[o]!=0)
   {
    printf("%d ",arr[o]);
   }
  }
  printf("\n");
  }
y=10;
sum=0;
u=1;
 }

}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
 int x,k;
 int z;
 int u=1;
 int y=10;
 int arr[5];
 int sum=0;
 scanf("%d",&x);
 for(int i=0;i<x;i++)
 {

  scanf("%d",&z);
  if (z<=10 && u==1)
  {
   printf("1\n");
   printf("%d",z);
  }
  else
  {
    for(int n=0;n<5;n++)
  {
   arr[n]=0;
  }
  for(int j=0;j<5;j++) {
   if (z%10!=0)
   {
    sum++;
    arr[j]=((z%10)*u);

   }
   u=u*10;
   z=z/(y);
  }
  printf("%d\n",sum);
  for(int o=0;o<5;o++)
  {
   if(arr[o]!=0)
   {
    printf("%d ",arr[o]);
   }
  }
  printf("\n");
  }
y=10;
sum=0;
u=1;
 }

}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
 int x,k;
 int z;
 int u=1;
 int y=10;
 int arr[5];
 int sum=0;
 scanf("%d",&x);
 for(int i=0;i<x;i++)
 {

  scanf("%d",&z);
  if (z<=10 && y==1)
  {
   printf("1");
   printf("%d",z);
  }
  else
  {
    for(int n=0;n<5;n++)
  {
   arr[n]=0;
  }
  for(int j=0;j<5;j++) {
   if (z%10!=0)
   {
    sum++;
    arr[j]=((z%10)*u);

   }
   u=u*10;
   z=z/(y);
  }
  printf("%d\n",sum);
  for(int o=0;o<5;o++)
  {
   if(arr[o]!=0)
   {
    printf("%d ",arr[o]);
   }
  }
  }
y=10;
sum=0;

 }

}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
 int x,k;
 int z;
 int u=1;
 int y=10;
 int arr[5];
 int sum=0;
 scanf("%d",&x);
 for(int i=0;i<x;i++)
 {

  scanf("%d",&z);
  if (z<=10 && u==1)
  {
   printf("1\n");
   printf("%d",z);
  }
  else
  {
    for(int n=0;n<5;n++)
  {
   arr[n]=0;
  }
  for(int j=0;j<5;j++) {
   if (z%10!=0)
   {
    sum++;
    arr[j]=((z%10)*u);

   }
   u=u*10;
   z=z/(y);
  }
  printf("%d\n",sum);
  for(int o=0;o<5;o++)
  {
   if(arr[o]!=0)
   {
    printf("%d ",arr[o]);
   }
  }
  }
y=10;
sum=0;
u=1;
 }

}


#include<stdio.h>
#include<math.h>
typedef long long int ll;
int main()
{
    ll t;
    scanf("%lld",&t);
    while(t--){
        ll n,count=0,i=0;
        scanf("%lld",&n);
        ll a[n];
        while(n!=0){
            if(n%10==0){
                n=n/10;
                i++;
            }
            else if((n%10)!=0){
                a[count]=(n%10)*(pow(10,i));
                count++;
                i++;
                n=n/10;
            }
        }
        printf("%lld\n",count);
        for(i=0;i<=count;i++){
            if(a[i]!=0)    printf("%lld ",a[i]);
        }
        printf("\n");
    }
}


#include<stdio.h>
#include<math.h>
typedef long long int ll;
int main()
{
    ll t;
    scanf("%lld",&t);
    while(t--){
        ll n,count=0,i=0,l;
        scanf("%lld",&n);
        l = log10(n);
        ll a[n];
        while(n!=0){
            if(n%10==0){
                n=n/10;
                i++;
            }
            else if((n%10)!=0){
                a[count]=(n%10)*(pow(10,i));
                count++;
                i++;
                n=n/10;
            }
        }
        printf("%lld\n",count);
        for(i=0;i<count;i++){
            if(a[i]!=0)    printf("%lld ",a[i]);
        }
        printf("\n");
    }
}


#include<stdio.h>
typedef long long int ll;
int main()
{
    ll t;
    scanf("%lld",&t);
    while(t--){
        ll n,l,i=1,k,count=0,c;
        scanf("%lld",&n);
        l=n;
        while(n!=0){
            k= n%10;
            n = n/10;
            if(k!=0) count++;
        }
        printf("%lld\n",count);
        while(l>0){
            k = l%10;
            l = l/10;
            if(k!=0){
                c = k*i;
                printf("%lld ",c);
            }
            i= 10*i;
        }
        printf("\n");
    }
}


#include<stdio.h>
#include<math.h>
typedef long long int ll;
int main()
{
    ll t;
    scanf("%lld",&t);
    while(t--){
        ll n,count=0,i=0,l;
        scanf("%lld",&n);
        l = log10(n);
        ll a[l];
        while(n!=0){
            if(n%10==0){
                n=n/10;
                i++;
            }
            else if((n%10)!=0){
                a[count]=(n%10)*(pow(10,i));
                count++;
                i++;
                n=n/10;
            }
        }
        printf("%lld\n",count);
        for(i=0;i<count;i++){
            if(a[i]!=0)    printf("%lld ",a[i]);
        }
        printf("\n");
    }
}


#include<stdio.h>
#include<math.h>
typedef long long int ll;
int main()
{
    ll t;
    scanf("%lld",&t);
    while(t--){
        ll n,count=0,i=0;
        scanf("%lld",&n);
        ll a[n];
        while(n!=0){
            if(n%10==0){
                n=n/10;
                i++;
            }
            else if((n%10)!=0){
                a[count]=(n%10)*(pow(10,i));
                count++;
                i++;
                n=n/10;
            }
        }
        printf("%lld\n",count);
        for(i=0;i<=count;i++){
            if(a[i]!=0)    printf("%lld ",a[i]);
        }
    }
}


__author__ = 'Utena'
def hash(x):
    a=0
    for j1 in x:
        a=(a*107+ord(j1))%100007
    return a
def get(q):
    l=len(q)
    e=1
    h=hash(q)
    for j in range(1,l+1):
        aj=q[-j]
        a,b,c=((h+(e*(ord('a')-ord(aj))))+100007)%100007,((h+(e*(ord('b')-ord(aj))))+100007)%100007,((h+(e*(ord('c')-ord(aj))))+100007)%100007
        e=(e*107)%100007
        if a in search[l] or b in search[l] or c in search[l]:
            return 'YES'
    return 'NO'
ans=[]
n,m=map(int,input().split())
search=[set()for i in range(600001)]
for i in range(n):
    s=input()
    search[len(s)].add(hash(s))
for i in range(m):
    q=input()
    ans.append(get(q))
print('\n'.join(ans))


__author__ = 'Utena'
def hash1(x):
    a=0
    for j1 in x:
        a=(a*1007+ord(j1))%10000007
    return a
def get(q):
    l=len(q)
    e=1
    h=hash(q)
    for j in range(1,l+1):
        aj=q[-j]
        a,b,c=((h+(e*(ord('a')-ord(aj))))+10000007*2)%10000007,((h+(e*(ord('b')-ord(aj))))+10000007*2)%10000007,((h+(e*(ord('c')-ord(aj))))+10000007*2)%10000007
        e=(e*1007)%10000007
        if aj=='a':
            if b in search[l] or c in search[l]:
                return 'YES'
        elif aj=='b':
            if a in search[l] or c in search[l]:
                return 'YES'
        elif aj=='c':
            if a in search[l] or b in search[l]:
                return 'YES'
    return 'NO'
ans=[]
n,m=map(int,input().split())
search=[set()for i in range(600001)]
for i in range(n):
    s=input()
    search[len(s)].add(hash(s))
for i in range(m):
    q=input()
    ans.append(get(q))
print('\n'.join(ans))


n,m = [int(i) for i in input().split()]
memory = set()
d = 31918781974729
ans = [None] * m

def Hash(x):
    t = 0
    mul = 1
    for char in x:
        t = (t + ord(char) * mul) % d
        mul = (mul * 2193) % d
    return t

for i in range(n):
    string = input()
    t = Hash(string)
    mul = 1
    for j in range(len(string)):
        for char in 'abc':
            if string[j] != char:
                memory.add((t + (ord(char) - ord(string[j])) * mul) % d)
        mul = (mul * 2193) % d
for i in range(m):
    string = input()
    t = Hash(string)
    if t in memory:
        ans[i] = 'YES'
    else:
        ans[i] = 'NO'
print(*ans, sep = '\n')


N = 9999999999999999999999999999999999999984
n,m=tuple(map(int,input().split()))
memory = set()
for _ in range(n):
    su = 0
    for letter in input():
        su = (su*203 + ord(letter))%N
    memory.add(su)
#print(memory)
answer = []
for _ in range(m):
    su = 0
    qu = input()
    for letter in qu:
        su = (su*203 + ord(letter))%N
    Notin = True
    for k in range(len(qu)):
        if Notin:
            for i in ['a','b','c']:
                if i!=qu[k]:
                    if (su + (ord(i)-ord(qu[k]))*pow(203,(len(qu)-1-k),N))%N in memory:
                        answer.append('YES')
                        Notin = False
        else:
            break
    if Notin: answer.append('NO')
print('\n'.join(answer))


N = 999999999999989
n,m=tuple(map(int,input().split()))
memory = set()
for _ in range(n):
    su = 0
    for letter in input():
        su = (su*103 + ord(letter))%N
    memory.add(su)
answer = []
for _ in range(m):
    su = 0
    qu = input()
    for letter in qu:
        su = (su*103 + ord(letter))%N
    Notin = True
    for k in range(len(qu)):
        if Notin:
            for i in ['a','b','c']:
                if i!=qu[k]:
                    if (su + (ord(i)-ord(qu[k]))*pow(103,(len(qu)-1-k),N))%N in memory:
                        answer.append('YES')
                        Notin = False
        else:
            break
    if Notin: answer.append('NO')
print('\n'.join(answer))


N = 9999999999999999999999999999999999999983
n,m=tuple(map(int,input().split()))
memory = set()
for _ in range(n):
    su = 0
    for letter in input():
        su = (su*203 + ord(letter))%N
    memory.add(su)
answer = []
for _ in range(m):
    su = 0
    qu = input()
    for letter in qu:
        su = (su*103 + ord(letter))%N
    Notin = True
    for k in range(len(qu)):
        if Notin:
            for i in ['a','b','c']:
                if i!=qu[k]:
                    if (su + (ord(i)-ord(qu[k]))*pow(103,(len(qu)-1-k),N))%N in memory:
                        answer.append('YES')
                        Notin = False
        else:
            break
    if Notin: answer.append('NO')
print('\n'.join(answer))


N = 9999999999999999999999999999999999999984
n,m=tuple(map(int,input().split()))
memory = set()
for _ in range(n):
    su = 0
    p = 1
    entry = input()
    for letter in entry:
        su = (su + p*ord(letter))%N
        p = (p*203)%N
    p = 1
    for letter in entry:
        for i in ['a','b','c']:
            if i != letter:
                memory.add((p*(ord(i)-ord(letter))+su)%N)
        p = (p*203)%N
answer  =[]
for _ in range(m):
    su = 0
    p = 1
    for letter in input():
        su = (su + p*ord(letter))%N
        p = (p*203)%N
    if su in memory:
        answer.append('YES')
    else:
        answer.append('NO')

print('\n'.join(answer))


N = 9999999999999999999999999999999999999983
n,m=tuple(map(int,input().split()))
memory = set()
for _ in range(n):
    su = 0
    for letter in input():
        su = (su*203 + ord(letter))%N
    memory.add(su)
#print(memory)
answer = []
for _ in range(m):
    su = 0
    qu = input()
    for letter in qu:
        su = (su*203 + ord(letter))%N
    Notin = True
    for k in range(len(qu)):
        if Notin:
            for i in ['a','b','c']:
                if i!=qu[k]:
                    if (su + (ord(i)-ord(qu[k]))*pow(203,(len(qu)-1-k),N))%N in memory:
                        answer.append('YES')
                        Notin = False
        else:
            break
    if Notin: answer.append('NO')
print('\n'.join(answer))


n,m=tuple(map(int,input().split()))

pos=set()
num={'a':1,'b':2,'c':3}
def hash1(s):
    ans = 0
    for ch in s:
        ans = ans*10 + num[ch]
    return ans

for _ in range(n):
    s = input()
    sh = hash1(s)
    l = len(s)
    pos.add(sh)
    for i in range(l):
        if s[i] == 'a':
            pos.add(int('1'+''.join(['0']*(l-i-1))) + sh)
            pos.add(int('2'+''.join(['0']*(l-i-1)))+sh)
        elif s[i] == 'b':
            pos.add(int('1'+''.join(['0']*(l-i-1)))+sh)
            pos.add( -int('1'+''.join(['0']*(l-i-1)))+sh)
        elif s[i] == 'c':
            pos.add(-int('1'+''.join(['0']*(l-i-1)))+sh)
            pos.add(-int('2'+''.join(['0']*(l-i-1)))+sh)
canfind = []
for _ in range(m):
    if hash1(input()) in pos:
        canfind.append('YES')
    else:
        canfind.append('NO')
print('\n'.join(canfind))


n,m=tuple(map(int,input().split()))

pos=set()
num={'a':1,'b':2,'c':3}
def hash1(s):
    ans = 0
    for ch in s:
        ans = ans*3 + num[ch]
    return ans

for _ in range(n):
    s = input()
    sh = hash1(s)
    l = len(s)
    for i in range(l):
        if s[i] == 'a':
            pos.add(int(1*3**(l-i-1)) + sh)
            pos.add(int(2*3**(l-i-1))+sh)
        elif s[i] == 'b':
            pos.add(int(1*3**(l-i-1))+sh)
            pos.add(-int(1*3**(l-i-1))+sh)
        elif s[i] == 'c':
            pos.add(-int(1*3**(l-i-1))+sh)
            pos.add(-int(2*3**(l-i-1))+sh)

canfind = []
for _ in range(m):
    if hash1(input()) in pos:
        canfind.append('YES')
    else:
        canfind.append('NO')
print('\n'.join(canfind))


n,m=tuple(map(int,input().split()))

pos=set()
num={'a':1,'b':2,'c':3}
def hash1(s):
    ans = 0
    for ch in s:
        ans = ans*10 + num[ch]
    return ans

for _ in range(n):
    s = input()
    sh = hash1(s)
    l = len(s)
    pos.add(sh)
    for i in range(l):
        if s[i] == 'a':
            pos.add(int('1'+''.join(['0']*(l-i-1))) + sh)
            pos.add(int('2'+''.join(['0']*(l-i-1)))+sh)
        elif s[i] == 'b':
            pos.add(int('1'+''.join(['0']*(l-i-1)))+sh)
            pos.add(-int('1'+''.join(['0']*(l-i-1)))+sh)
        elif s[i] == 'c':
            pos.add(-int('1'+''.join(['0']*(l-i-1)))+sh)
            pos.add(-int('2'+''.join(['0']*(l-i-1)))+sh)
canfind = []
for _ in range(m):
    if hash1(input()) in pos:
        canfind.append('YES')
    else:
        canfind.append('NO')
print('\n'.join(canfind))


N = 99999999999998912749863598726345876341
n,m=tuple(map(int,input().split()))
memory = set()
for _ in range(n):
    su = 0
    for letter in input():
        su = (su*203 + ord(letter))%N
    memory.add(su)
answer = []
for _ in range(m):
    su = 0
    qu = input()
    for letter in qu:
        su = (su*103 + ord(letter))%N
    Notin = True
    for k in range(len(qu)):
        if Notin:
            for i in ['a','b','c']:
                if i!=qu[k]:
                    if (su + (ord(i)-ord(qu[k]))*pow(103,(len(qu)-1-k),N))%N in memory:
                        answer.append('YES')
                        Notin = False
        else:
            break
    if Notin: answer.append('NO')
print('\n'.join(answer))


n,m=tuple(map(int,input().split()))

pos=set()
num={'a':1,'b':2,'c':3}
def hash1(s):
    ans = 0
    for ch in s:
        ans = ans*10 + num[ch]
    return ans

for _ in range(n):
    s = input()
    sh = hash1(s)
    l = len(s)
    for i in range(l):
        if s[i] == 'a':
            pos.add(int('1'+''.join(['0']*(l-i-1))) + sh)
            pos.add(int('2'+''.join(['0']*(l-i-1)))+sh)
        elif s[i] == 'b':
            pos.add(int('1'+''.join(['0']*(l-i-1)))+sh)
            pos.add( -int('1'+''.join(['0']*(l-i-1)))+sh)
        elif s[i] == 'c':
            pos.add(-int('1'+''.join(['0']*(l-i-1)))+sh)
            pos.add(-int('2'+''.join(['0']*(l-i-1)))+sh)
canfind = []
for _ in range(m):
    if hash1(input()) in pos:
        canfind.append('YES')
    else:
        canfind.append('NO')
print('\n'.join(canfind))


n,m=tuple(map(int,input().split()))

pos=set()
num={'a':1,'b':2,'c':3}
def hash1(s):
    ans = 0
    for ch in s:
        ans = ans*10 + num[ch]
    return ans

for _ in range(n):
    s = input()
    sh = hash1(s)
    l = len(s)
    pos.add(sh)
    for i in range(l):
        if s[i] == 'a':
            pos.add(int(1*10**(l-i-1))+sh)
            pos.add(int(2*10**(l-i-1))+sh)
        if s[i] == 'b':
            pos.add(int(1*10**(l-i-1))+sh)
            pos.add(-int(1*10**(l-i-1))+sh)
        if s[i] == 'c':
            pos.add(int(-1*10**(l-i-1))+sh)
            pos.add(int(-2*10**(l-i-1))+sh)
canfind = []
for _ in range(m):
    if hash1(input()) in pos:
        canfind.append('YES')
    else:
        canfind.append('NO')
print('\n'.join(canfind))


n,m=tuple(map(int,input().split()))

pos=set()
num={'a':1,'b':2,'c':3}
def hash1(s):
    ans = 0
    for ch in s:
        ans = ans*10 + num[ch]
    return ans

for _ in range(n):
    s = input()
    sh = hash1(s)
    l = len(s)
    for i in range(l):
        if s[i] == 'a':
            pos.add(int(1*10**(l-i-1)) + sh)
            pos.add(int(2*10**(l-i-1))+sh)
        elif s[i] == 'b':
            pos.add(int(1*10**(l-i-1))+sh)
            pos.add(-int(1*10**(l-i-1))+sh)
        elif s[i] == 'c':
            pos.add(-int(1*10**(l-i-1))+sh)
            pos.add(-int(2*10**(l-i-1))+sh)
canfind = []
for _ in range(m):
    if hash1(input()) in pos:
        canfind.append('YES')
    else:
        canfind.append('NO')
print('\n'.join(canfind))


n,m=tuple(map(int,input().split()))

pos=set()
num={'a':1,'b':2,'c':3}
def hash1(s):
    ans = 0
    for ch in s:
        ans = ans*3 + num[ch]
    return ans

def find(s, num):
    if len(s)<=1:
        try:
            return s[0]==num
        except IndexError:
            return False
    else:
        aaa = len(s)//2
        mid = s[aaa]
        if mid==num:
            return True
        elif mid<num:
            return find(s[aaa+1:],num)
        else:
            return find(s[:aaa],num)

for _ in range(n):
    s = input()
    sh = 0
    for ch in s:
        sh = sh*3 + num[ch]
    l = len(s)
    for i in range(l):
        if s[i] == 'a':
            pos.add(int(1*3**(l-i-1)) + sh)
            pos.add(int(2*3**(l-i-1))+sh)
        elif s[i] == 'b':
            pos.add(int(1*3**(l-i-1))+sh)
            pos.add(-int(1*3**(l-i-1))+sh)
        elif s[i] == 'c':
            pos.add(-int(1*3**(l-i-1))+sh)
            pos.add(-int(2*3**(l-i-1))+sh)
pos = sorted(list(pos))
canfind = []
for _ in range(m):
    ans = 0
    for ch in input():
        ans = ans*3 + num[ch]
    found = find(pos, ans)
    if found:
        canfind.append('YES')
    else:
        canfind.append('NO')
print('\n'.join(canfind))


from sys import stdin
from functools import reduce
from collections import defaultdict

_data = iter(stdin.read().split('\n'))
def input():
    while True:
        return next(_data)

n, m = [int(x) for x in input().split()]
B = 10007
MOD = 1000000000000000003
h = lambda s: reduce(lambda s, c: (B * s + ord(c)) % MOD, s, 0)
hs = defaultdict(set)

def insert(s):
    hs[len(s)].add(h(s))

def find(s):
    v = h(s)
    b = 1
    for c in reversed(s):
        for d in 'abc':
            if c != d:
                u = (v - b * ord(c) + b * ord(d)) % MOD
                if u in hs[len(s)]:
                    return True
        b *= B
        b %= MOD
    return False

for i in range(n):
    s = input()
    insert(s)
buf = []
for i in range(m):
    s = input()
    buf.append('YES' if find(s) else 'NO')
print('\n'.join(buf))


from sys import stdin
from functools import reduce
from collections import defaultdict

_data = iter(stdin.read().split('\n'))

def insert(s):
    hs[len(s)].add(h(s))

def found(s):
    v = h(s)
    b = 1
    for c in reversed(s):
        for d in 'abc':
            if c != d:
                u = (v - b * ord(c) + b * ord(d)) % MOD
                if u in hs[len(s)]:
                    return True
        b *= B
        b %= MOD
    return False

n, m = [int(x) for x in input().split()]
B = 10007
MOD = 1000000000000000003
h = lambda s: reduce(lambda s, c: (B * s + ord(c)) % MOD, s, 0)
hs = defaultdict(set)

for i in range(n):
    s = input()
    insert(s)

text = []

for i in range(m):
    s = input()
    text.append('YES' if found(s) else 'NO')
print('\n'.join(text))


from sys import stdin
from functools import reduce
from collections import defaultdict

_data = iter(stdin.read().split('\n'))
def input():
    while True:
        return next(_data)

def insert(s):
    hs[len(s)].add(h(s))

def found(s):
    v = h(s)
    b = 1
    for c in reversed(s):
        for d in 'abc':
            if c != d:
                u = (v - b * ord(c) + b * ord(d)) % MOD
                if u in hs[len(s)]:
                    return True
        b *= B
        b %= MOD
    return False

n, m = [int(x) for x in input().split()]
B = 10007
MOD = 1000000000000000003
h = lambda s: reduce(lambda s, c: (B * s + ord(c)) % MOD, s, 0)
hs = defaultdict(set)

for i in range(n):
    s = input()
    insert(s)

text = []

for i in range(m):
    s = input()
    text.append('YES' if found(s) else 'NO')
print('\n'.join(text))


n,m=map(int,input().split())
M=9999999999999983
v=set()
for i in range(n):
	s=input()
	l=len(s)
	pow=1
	h=0
	for i in range(l):
		h,pow=(h+ord(s[i])*pow)%M,(pow*203)%M
	pow=1
	for i in range(l):
		for j in range(97,100):
			if ord(s[i])!=j:
				v.add((h+(j-ord(s[i]))*pow)%M)
		pow=(pow*203)%M
ans=[]
for i in range(m):
	s=input()
	pow=1
	h=0
	for i in range(len(s)):
		h,pow=(h+ord(s[i])*pow)%M,(pow*203)%M
	ans.append('YES' if h in v else 'NO')
print('\n'.join(ans))


n, m = map(int, raw_input().split(' '))

p = 10000007
hash_dict = {}

for i in range(0, n):
    s = raw_input()
    s_num = [ord(c) - ord('a') for c in s]
    h = 0
    for c in s_num:
        h = ((h * 3) + c) % p
    if hash_dict.has_key(h):
        hash_dict[h][s] = 1
    else:
        hash_dict[h] = {s : 1}

for i in range(0, m):
    s = raw_input()
    s_num = [ord(c) - ord('a') for c in s]
    h = 0
    for c in s_num:
        h = ((h * 3) + c) % p
    res = False
    mod = 1
    for j in xrange(len(s)):
        for x in [0, 1, 2]:
            if s_num[j] == x:
                continue
            h_now = (h + (x - s_num[j]) * mod + p) % p
            if hash_dict.has_key(h_now):
                s_now = ''.join([s[0:j], chr(ord(s[j]) + x - s_num[j]), s[j + 1 :]])
                if hash_dict[h_now].has_key(s_now):
                    res = True
                    break
        if res:
            break
        mod = (mod * 3) % p
    if res:
        print "YES"
    else:
        print "NO"


n, m = map(int, raw_input().split(' '))

mem_dict = {}
for i in range(0, n):
    s = raw_input()
    mem_dict[s] = 1

for i in range(0, m):
    s = raw_input()
    res = False
    for j in range(0, len(s)):
        for x in ['a', 'b', 'c']:
            if s[j] == x:
                continue
            now = s[0 : j] + x + s[j + 1 : ]
            if mem_dict.has_key(now):
                res = True
                break
        if res:
            break
    if res:
        print "YES"
    else:
        print "NO"


n, m = map(int, raw_input().split(' '))

mem_dict = {}
for i in range(0, n):
    s = raw_input()
    mem_dict[s] = 1

for i in range(0, m):
    s = [c for c in raw_input()]
    res = False
    for j in range(0, len(s)):
        tmp = s[j]
        for x in ['a', 'b', 'c']:
            if tmp == x:
                continue
            s[j] = x
            if mem_dict.has_key(''.join(s)):
                res = True
                break
        if res:
            break
        s[j] = tmp
    if res:
        print "YES"
    else:
        print "NO"


n, m = map(int, raw_input().split(' '))

p = 10000007
hash_dict = {}

for i in range(0, n):
    s = raw_input()
    s_num = [ord(c) - ord('a') for c in s]
    h = 0
    for c in s_num:
        h = ((h * 3) + c) % p
    #print h
    if hash_dict.has_key(h):
        hash_dict[h][s] = 1
    else:
        hash_dict[h] = {s : 1}

for i in range(0, m):
    s = raw_input()
    s_num = [ord(c) - ord('a') for c in s]
    h = 0
    for c in s_num:
        h = ((h * 3) + c) % p
    #print h
    res = False
    mod = 1
    for j in xrange(len(s) - 1, -1, -1):
        for x in [0, 1, 2]:
            if s_num[j] == x:
                continue
            h_now = (h + (x - s_num[j]) * mod + p) % p
            #print h_now
            if hash_dict.has_key(h_now):
                s_now = ''.join([s[0:j], chr(ord(s[j]) + x - s_num[j]), s[j + 1 :]])
                #print s_now
                if hash_dict[h_now].has_key(s_now):
                    res = True
                    break
        if res:
            break
        mod = (mod * 3) % p
    if res:
        print "YES"
    else:
        print "NO"


mod = 0xffffffffffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 1009 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 1009 + ord(st[i]) - ord('a') + 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    if st in dicst:
        return
    dicst[st] = 0
    a = gethashlist(st)
    lenst = len(st)
    t = 0
    for i in a:
        dic[(lenst,t,i[0] ,i[1])] = \
                        dic.get((lenst,t,i[0] ,i[1]),0) | i[2]
        t+=1
def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    t = 0
    for i in a:
        if (((dic.get((lenst,t,i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
        t+=1
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
dicst = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"


mod = 0xffffffffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ord(st[i]) - ord('a')+ 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    if st in dicst:
        return;
    dicst[st] = 0
    a = gethashlist(st)
    lenst = len(st)

    for i in a:
        dic[(i[0] ,i[1])] = \
                        dic.get((i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
dicst = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"
"""
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

YES
NO
NO
"""


mod = 0xffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ord(st[i]) - ord('a')+ 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"
"""
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

YES
NO
NO
"""


mod = 0xfffffffffffffffffffffffffffffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 1009 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 1009 + ord(st[i]) - ord('a') + 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    if st in dicst:
        return
    dicst[st] = 0
    a = gethashlist(st)
    lenst = len(st)
    t = 0
    for i in a:
        dic[(lenst,t,i[0] ,i[1])] = \
                        dic.get((lenst,t,i[0] ,i[1]),0) | i[2]
        t+=1
def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    t = 0
    for i in a:
        if (((dic.get((lenst,t,i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
        t+=1
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
dicst = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"


mod = 0xffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ord(st[i]) - ord('a') + 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(lenst,i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((lenst,i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"
"""
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

YES
NO
NO
"""


mod = 0xffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ' abc'.find(i)) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ' abc'.find(st[i])) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(lenst,i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((lenst,i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"
"""
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

YES
NO
NO
"""


mod = 0xffffffffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ord(st[i]) - ord('a')+ 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"
"""
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

YES
NO
NO
"""


mod = 0xffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ord(i) - ord('a')) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ord(st[i]) - ord('a')) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(lenst,i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((lenst,i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"
"""
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

YES
NO
NO
"""


mod = 1000000007
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ' abc'.find(i)) % mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ' abc'.find(st[i])) % mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], st[i]))
    return ans

def updata(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(lenst,i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),set()) | set(i[2])

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if dic.get((lenst,i[0] ,i[1]),set()) - set(i[2]):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"
"""
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

YES
NO
NO
"""


mod = 0xffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ord(st[i]) - ord('a') + 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    if st in dicst:
        return
    dicst[st] = 0
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(lenst,i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((lenst,i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
dicst = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"


mod = 0xffffffffffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 1009 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 1009 + ord(st[i]) - ord('a') + 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    if st in dicst:
        return
    dicst[st] = 0
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(lenst,i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((lenst,i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
dicst = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"


mod = 1000000007
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + 'abc'.find(i)) % mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + 'abc'.find(st[i])) % mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], st[i]))
    return ans

def updata(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(lenst,i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),set()) | set(i[2])

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if dic.get((lenst,i[0] ,i[1]),set()) - set(i[2]):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"
"""
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

YES
NO
NO
"""


mod = 0xffffffffffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 1009 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 1009 + ord(st[i]) - ord('a') + 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    if st in dicst:
        return
    dicst[st] = 0
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(lenst,i,i[0] ,i[1])] = \
                        dic.get((lenst,i,i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((lenst,i,i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
dicst = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"


mod = 0xffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ' abc'.find(i)) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ' abc'.find(st[i])) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], st[i]))
    #print ans
    return ans

def updata(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(lenst,i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),set()) | set(i[2])

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if dic.get((lenst,i[0] ,i[1]),set()) - set(i[2]):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"
"""
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

YES
NO
NO
"""


mod = 0xffffffffffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ord(st[i]) - ord('a') + 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    if st in dicst:
        return
    dicst[st] = 0
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(lenst,i[0] ,i[1])] = \
                        dic.get((lenst,i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((lenst,i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
dicst = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"


mod = 0xffffffffffffff
def gethashlist(st):
    a = [0]
    for i in st:
        a.append((a[-1] * 107 + ord(i) - ord('a') + 1) & mod)
    b = [0]
    for i in xrange(len(st) - 1, -1, -1):
        b.append((b[-1] * 107 + ord(st[i]) - ord('a')+ 1) & mod)
    ans = []
    lenst = len(st)
    for i in xrange(lenst):
        ans.append((a[i],b[lenst - i - 1], 1 << 'abc'.find(st[i]) ))
    #print ans
    return ans

def updata(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        dic[(i[0] ,i[1])] = \
                        dic.get((i[0] ,i[1]),0) | i[2]

def check(dic, st):
    a = gethashlist(st)
    lenst = len(st)
    for i in a:
        if (((dic.get((i[0] ,i[1]),0) ^ 7) | i[2]) ^ 7):
            return True
    return False

n, m = map(int,raw_input().split(" "))
dic = {}
for i in xrange(n):
    st = raw_input()
    updata(dic, st)

for i in xrange(m):
    st = raw_input()
    if check(dic, st):
        print "YES"
    else:
        print "NO"
"""
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

YES
NO
NO
"""


#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import math
import random
import operator
from fractions import Fraction, gcd
from decimal import Decimal, getcontext
from itertools import product, permutations, combinations
from Queue import Queue, PriorityQueue
from collections import deque, defaultdict, Counter

MODS = [
    random.randint(1 << 30, 1 << 31)
    for _ in xrange(5)
]

digits = dict(a=0, b=1, c=2)

def ton(s):
    return [digits[c] for c in s]

def hashik(ds, m):
    res = 0
    for c in ds:
        res = res * 3 + c
        res %= m
    return res

n, Q = map(int, raw_input().split())
dbs = {m: {} for m in MODS}
for _ in xrange(n):
    ds = ton(raw_input())
    for m in MODS:
        if len(ds) not in dbs[m]:
            dbs[m][len(ds)] = set()
        dbs[m][len(ds)].add(hashik(ds, m))

def check(ds):
    h0s = {m: hashik(ds, m) for m in MODS}
    for i in xrange(len(ds)):
        dist = len(ds) - 1 - i
        for m in MODS:
            dbm = dbs[m].get(len(ds), ())
            if not dbm:
                break
            mult = pow(3, dist, m)
            h0 = h0s[m] - mult * ds[i]
            h0 %= m
            for c in (0, 1, 2):
                if (h0 + mult * c) % m in dbm:
                    # print >>sys.stderr, "MATCH", i, c
                    break
            else:
                break
        else:
            return 1
    return 0

for _ in xrange(Q):
    s = raw_input()
    # print _, s
    ds = ton(s)
    print "YES" if check(ds) else "NO"


#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import math
import random
import operator
from fractions import Fraction, gcd
from decimal import Decimal, getcontext
from itertools import product, permutations, combinations
from Queue import Queue, PriorityQueue
from collections import deque, defaultdict, Counter

MODS = [
    random.randint(1 << 30, 1 << 31)
    for _ in xrange(2)
]

digits = dict(a=0, b=1, c=2)

def ton(s):
    return [digits[c] for c in s]

def hashik(ds, m):
    res = 0
    for c in ds:
        res = res * 3 + c
        res %= m
    return res

added = set()
mxlen = 0
n, Q = map(int, raw_input().split())
dbs = [{} for m in MODS]
for _ in xrange(n):
    s = raw_input()
    if s in added:
        continue
    added.add(s)

    ds = ton(s)
    mxlen = max(mxlen, len(ds))
    for dbm, m in zip(dbs, MODS):
        if len(ds) not in dbm:
            dbm[len(ds)] = set()
        dbm[len(ds)].add(hashik(ds, m))

pow3 = {}
for mod in MODS:
    lst = pow3[mod] = [0] * (mxlen + 1)
    r = 1
    for i in xrange(mxlen + 1):
        lst[i] = r
        r = (r * 3) % mod

def check(ds):
    xxx = [(m, hashik(ds, m), dbm) for dbm, m in zip(dbs, MODS)]
    for i in xrange(len(ds)):
        dist = len(ds) - 1 - i
        for m, h0, dbm in xxx:
            dbm = dbm.get(len(ds), ())
            if not dbm:
                break
            # mult = pow(3, dist, m)
            mult = pow3[m][dist]
            h0 -= mult * ds[i]
            h0 %= m
            for c in (0, 1, 2):
                if c == ds[i]:
                    continue
                if (h0 + mult * c) % m in dbm:
                    # print >>sys.stderr, "MATCH", i, c
                    break
            else:
                break
        else:
            return 1
    return 0

cached = {}
for _ in xrange(Q):
    s = raw_input()
    try:
        res = cached[s]
    except KeyError:
        res = cached[s] = check(ton(s))
    sys.stdout.write("YES\n" if res else "NO\n")


#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import math
import random
import operator
from fractions import Fraction, gcd
from decimal import Decimal, getcontext
from itertools import product, permutations, combinations
from Queue import Queue, PriorityQueue
from collections import deque, defaultdict, Counter

MODS = [
    random.randint(1 << 30, 1 << 31)
    for _ in xrange(2)
]

digits = dict(a=0, b=1, c=2)

def ton(s):
    return [digits[c] for c in s]

def hashik(ds, m):
    res = 0
    for c in ds:
        res = res * 3 + c
        res %= m
    return res

added = set()
mxlen = 0
n, Q = map(int, raw_input().split())
dbs = [{} for m in MODS]
for _ in xrange(n):
    s = sys.stdin.readline()[:-1]
    if s in added:
        continue
    added.add(s)

    ds = ton(s)
    mxlen = max(mxlen, len(ds))
    for dbm, m in zip(dbs, MODS):
        if len(ds) not in dbm:
            dbm[len(ds)] = set()
        dbm[len(ds)].add(hashik(ds, m))

pow3 = {}
for mod in MODS:
    lst = pow3[mod] = [0] * (mxlen + 1)
    r = 1
    for i in xrange(mxlen + 1):
        lst[i] = r
        r = (r * 3) % mod

def check(ds):
    xxx = [(m, hashik(ds, m), dbm) for dbm, m in zip(dbs, MODS)]
    for i in xrange(len(ds)):
        dist = len(ds) - 1 - i
        for m, h0, dbm in xxx:
            dbm = dbm.get(len(ds), ())
            if not dbm:
                break
            # mult = pow(3, dist, m)
            mult = pow3[m][dist]
            h0 -= mult * ds[i]
            h0 %= m
            for c in (0, 1, 2):
                if c == ds[i]:
                    continue
                if (h0 + mult * c) % m in dbm:
                    # print >>sys.stderr, "MATCH", i, c
                    break
            else:
                break
        else:
            return 1
    return 0

cached = {}
for _ in xrange(Q):
    s = sys.stdin.readline()[:-1]
    if not s in cached:
        cached[s] = check(ton(s))
    res = cached[s]
    # try:
    #     res = cached[s]
    # except KeyError:
    #     res = cached[s] = check(ton(s))
    # res = check(ton(s))
    sys.stdout.write("YES\n" if res else "NO\n")


from sys import stdin, stdout
from collections import defaultdict
def main():
    n, m = map(int, stdin.readline().split())
    ss = stdin.read().split()
    mod0 = 1000000007
    mod1 = 1000000009
    toi = {'a': 0, 'b': 1, 'c': 2}
    d = defaultdict(set)
    for s in ss[:n]:
        k0 = k1 = 0
        for c in s:
            k0 = (k0 + k0 + k0 + toi[c]) % mod0
            k1 = (k1 + k1 + k1 + toi[c]) % mod1
        d[len(s)].add((k0, k1))
    al = [(1, 2), (-1, 1), (-2, -1)]
    def f(s):
        k0 = k1 = 0
        for c in s:
            k0 = (k0 + k0 + k0 + toi[c]) % mod0
            k1 = (k1 + k1 + k1 + toi[c]) % mod1
        S = d[len(s)]
        f = 0
        x0 = x1 = 1
        for c in reversed(s):
            c = toi[c]
            for a in al[c]:
                nk = ((k0 + a * x0) % mod0, (k1 + a * x1) % mod1)
                if nk in S:
                    return "YES"
            x0 = x0 * 3 % mod0
            x1 = x1 * 3 % mod1
        return "NO"
    stdout.write("\n".join(map(f, ss[n:])))
main()


from sys import stdin, stdout
from collections import defaultdict
def main():
    n, m = map(int, stdin.readline().split())
    ss = stdin.read().split()
    mod0 = 1000000007
    mod1 = 1000000009
    toi = {'a': 0, 'b': 1, 'c': 2}
    d = defaultdict(set)
    for s in ss[:n]:
        k0 = k1 = 0
        for c in s:
            k0 = (k0 + k0 + k0 + toi[c]) % mod0
            k1 = (k1 + k1 + k1 + toi[c]) % mod1
        d[len(s)].add((k0, k1))
    al = [(1, 2), (-1, 1), (-2, -1)]
    ans = []
    aa = ans.append
    for s in ss[n:]:
        k0 = k1 = 0
        for c in s:
            k0 = (k0 + k0 + k0 + toi[c]) % mod0
            k1 = (k1 + k1 + k1 + toi[c]) % mod1
        l = len(s)
        f = 0
        x0 = x1 = 1
        for c in reversed(s):
            c = toi[c]
            for a in al[c]:
                nk = ((k0 + a * x0) % mod0, (k1 + a * x1) % mod1)
                if nk in d[l]:
                    f = 1
            x0 = x0 * 3 % mod0
            x1 = x1 * 3 % mod1
        aa("YES" if f else "NO")
    stdout.write("\n".join(ans))
main()


from sys import stdin, stdout
from collections import defaultdict
def main():
    n, m = map(int, stdin.readline().split())
    ss = stdin.read().split()
    e0 = [1]
    e1 = [1]
    mod0 = 1000000007
    mod1 = 1000000009
    for i in xrange(600010):
        e0.append(e0[-1] * 3 % mod0)
        e1.append(e1[-1] * 3 % mod1)
    toi = {'a': 0, 'b': 1, 'c': 2}
    d = defaultdict(set)
    for s in ss[:n]:
        k0 = k1 = 0
        for i, c in enumerate(s):
            k0 += toi[c] * e0[i]
            k0 %= mod0
            k1 += toi[c] * e1[i]
            k1 %= mod1
        d[len(s)].add((k0, k1))
    al = [(1, 2), (-1, 1), (-2, -1)]
    ans = []
    aa = ans.append
    for s in ss[n:]:
        k0 = k1 = 0
        for i, c in enumerate(s):
            k0 += toi[c] * e0[i]
            k0 %= mod0
            k1 += toi[c] * e1[i]
            k1 %= mod1
        l = len(s)
        f = 0
        for i, c in enumerate(s):
            c = toi[c]
            for a in al[c]:
                nk = ((k0 + a * e0[i]) % mod0, (k1 + a * e1[i]) % mod1)
                if nk in d[l]:
                    f = 1
        aa("YES" if f else "NO")
    stdout.write("\n".join(ans))
main()


from sys import stdin, stdout
from collections import defaultdict
def main():
    n, m = map(int, stdin.readline().split())
    ss = stdin.read().split()
    e0 = [1]
    e1 = [1]
    mod0 = 1000000007
    mod1 = 1000000009
    for i in xrange(600010):
        e0.append(e0[-1] * 3 % mod0)
        e1.append(e1[-1] * 3 % mod1)
    toi = {'a': 0, 'b': 1, 'c': 2}
    d = defaultdict(set)
    def h(s):
        return (sum(toi[c] * e0[i] for i, c in enumerate(s)) % mod0, sum(toi[c] * e1[i] for i, c in enumerate(s)) % mod1)
    for s in ss[:n]:
        d[len(s)].add(h(s))
    al = [(1, 2), (-1, 1), (-2, -1)]
    ans = []
    aa = ans.append
    for s in ss[n:]:
        k0, k1 = h(s)
        l = len(s)
        f = 0
        for i, c in enumerate(s):
            c = toi[c]
            for a in al[c]:
                nk = ((k0 + a * e0[i]) % mod0, (k1 + a * e1[i]) % mod1)
                if nk in d[l]:
                    f = 1
        aa("YES" if f else "NO")
    stdout.write("\n".join(ans))
main()


from sys import stdin, stdout
from collections import defaultdict
def main():
    n, m = map(int, stdin.readline().split())
    ss = stdin.read().split()
    mod0 = 1000000007
    mod1 = 1000000009
    toi = {'a': 0, 'b': 1, 'c': 2}
    d = defaultdict(set)
    for s in ss[:n]:
        k0 = k1 = 0
        for c in s:
            k0 = (k0 + k0 + k0 + toi[c]) % mod0
            k1 = (k1 + k1 + k1 + toi[c]) % mod1
        d[len(s)].add((k0, k1))
    al = [(1, 2), (-1, 1), (-2, -1)]
    def f(s):
        k0 = k1 = 0
        for c in s:
            k0 = (k0 + k0 + k0 + toi[c]) % mod0
            k1 = (k1 + k1 + k1 + toi[c]) % mod1
        l = len(s)
        f = 0
        x0 = x1 = 1
        for c in reversed(s):
            c = toi[c]
            for a in al[c]:
                nk = ((k0 + a * x0) % mod0, (k1 + a * x1) % mod1)
                if nk in d[l]:
                    return "YES"
            x0 = x0 * 3 % mod0
            x1 = x1 * 3 % mod1
        return "NO"
    stdout.write("\n".join(map(f, ss[n:])))
main()


from sys import stdin, stdout
from collections import defaultdict
def main():
    n, m = map(int, stdin.readline().split())
    ss = stdin.read().split()
    e0 = [1]
    e1 = [1]
    mod0 = 1000000007
    mod1 = 1000000009
    for i in xrange(300010):
        e0.append(e0[-1] * 3 % mod0)
        e1.append(e1[-1] * 3 % mod1)
    toi = {'a': 0, 'b': 1, 'c': 2}
    d = defaultdict(set)
    def h(s):
        return (sum(toi[c] * e0[i] for i, c in enumerate(s)) % mod0, sum(toi[c] * e1[i] for i, c in enumerate(s)) % mod1)
    for s in ss[:n]:
        d[len(s)].add(h(s))
    al = [(1, 2), (-1, 1), (-2, -1)]
    ans = []
    aa = ans.append
    for s in ss[n:]:
        k0, k1 = h(s)
        l = len(s)
        f = 0
        for i, c in enumerate(s):
            c = toi[c]
            for a in al[c]:
                nk = ((k0 + a * e0[i]) % mod0, (k1 + a * e1[i]) % mod1)
                if nk in d[l]:
                    f = 1
        aa("YES" if f else "NO")
    stdout.write("\n".join(ans))
main()


# -*- coding: utf-8 -*-

d = set()
ss = []

MOD = (2**64)-1

def calc(s):
  c = 0
  for i, w in enumerate(s):
    c += (11**i)*ord(w)
    c %= MOD
  return c

n, m = map(int, raw_input().split())
for _ in xrange(n):
  s = raw_input()
  ss.append(s)
  c = calc(s)
  for i, w in enumerate(s):
    it = ['a', 'b', 'c']
    it.remove(w)
    for r in it:
      k = c + MOD - ord(w)*(11**i) + ord(r)*(11**i)
      k %= MOD
      d.add(k)

for _ in xrange(m):
  s = raw_input()
  c = calc(s)
  if c in d:
    print 'YES'
  else:
    print 'NO'


# -*- coding: utf-8 -*-

class mydict(dict):

  def __missing__(self, key):
    self[key] = []
    return self[key]

d = mydict()
ss = []

MOD = (1<<31)-1

def calc(s):
  c = 0
  for i, w in enumerate(s):
    c += (1<<i)*ord(w)
    c %= MOD
  return c

n, m = map(int, raw_input().split())
for _ in xrange(n):
  s = raw_input()
  ss.append(s)
  c = calc(s)
  for i, w in enumerate(s):
    it = ['a', 'b', 'c']
    it.remove(w)
    for r in it:
      k = c + MOD - ord(w)*(1<<i) + ord(r)*(1<<i)
      k %= MOD
      d[k].append(_)

for _ in xrange(m):
  s = raw_input()
  c = calc(s)
  if c in d:
    print 'YES'
  else:
    print 'NO'


# -*- coding: utf-8 -*-

n, m = map(int, raw_input().split())

d = set()

import string

for i in xrange(n):
  s = raw_input()
  d.add(s)

for _ in xrange(m):
  s = raw_input()
  flag = 0
  for i in xrange(len(s)):
    if flag: break
    for w in string.lowercase:
      if w == s[i]: continue
      ts = ''.join([ s[:i], w, s[i+1:] ])
      if ts in d:
        print 'YES'
        flag = 1
        break

  if not flag:
    print 'NO'


# -*- coding: utf-8 -*-

n, m = map(int, raw_input().split())

d = set()

import string
import hashlib

for i in xrange(n):
  s = raw_input()
  for j in xrange(len(s)):
    d.add( hashlib.md5( ''.join([s[:j], s[j+1:], str(j)]) ).hexdigest() )

for i in xrange(m):
  s = raw_input()
  flag = 0
  for j in xrange(len(s)):
    if hashlib.md5( ''.join([s[:j], s[j+1:], str(j)]) ).hexdigest() in d:
      flag = 1
      print 'YES'
      break
  if not flag:
    print 'NO'


# -*- coding: utf-8 -*-

class mydict(dict):

  def __missing__(self, key):
    self[key] = []
    return self[key]

d = mydict()
ss = []

MOD = 1000000007

def calc(s):
  c = 0
  for i, w in enumerate(s):
    c += (i+1)*ord(w)
    c %= MOD
  return c

n, m = map(int, raw_input().split())
for _ in xrange(n):
  s = raw_input()
  ss.append(s)
  c = calc(s)
  for i, w in enumerate(s):
    it = ['a', 'b', 'c']
    it.remove(w)
    for r in it:
      k = c + MOD - ord(w)*(i+1) + ord(r)*(i+1)
      k %= MOD
      d[k].append(_)

for _ in xrange(m):
  s = raw_input()
  c = calc(s)
  if c in d:
    print 'YES'
  else:
    print 'NO'