#include <bits/stdc++.h>
using namespace std;
int a[1000006], x[1000006], y[1000006];
char a1[1000006];
int main() {
  int i, j;
  int n, m;
  int len;
  scanf("%s", a1);
  scanf("%d%d", &n, &m);
  len = strlen(a1);
  for (i = 0; i < len; ++i) a[i] = a1[i] - '0';
  int temp = 0;
  for (i = 0; i < len; ++i) {
    x[i] = ((temp % n) * 10 + a[i]) % n;
    temp = x[i];
  }
  temp = 0;
  int k = 0, ant = 10;
  for (i = len - 1; i >= 0; --i) {
    if (i == len - 1)
      ant = 1;
    else
      ant = ant * 10 % m;
    y[i] = (temp + ant * a[i]) % m;
    temp = y[i];
  }
  for (i = 1; i < len; ++i) {
    if (a[i] != 0 && x[i - 1] == 0 && y[i] == 0) {
      printf("YES\n");
      for (j = 0; j < i; ++j) printf("%d", a[j]);
      printf("\n");
      for (j = i; j < len; ++j) printf("%d", a[j]);
      printf("\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}
