#include <bits/stdc++.h>
using namespace std;
const int maxl = 1000000 + 10;
char st[maxl];
long long a, b, len, ans = 0;
long long qian[maxl];
void reading() {
  gets(st + 1);
  scanf("%d%d", &a, &b);
};
void chuli() {
  int now = 0, d, c;
  len = strlen(st + 1);
  for (int i = 1; i <= len; i++) {
    now = (now * 10 + (st[i] - '0')) % a;
    qian[i] = now;
  };
  now = 0;
  d = 1;
  for (int i = len; i > 1; i--) {
    c = d * (st[i] - '0') % b;
    now = (c + now) % b;
    d = (d * 10) % b;
    if (now == 0 && qian[i - 1] == 0 && (st[i] != '0')) {
      ans = i - 1;
      break;
    };
  };
};
void print() {
  printf("YES\n");
  for (int i = 1; i <= ans; i++) printf("%c", st[i]);
  printf("\n");
  for (int i = ans + 1; i <= len; i++) printf("%c", st[i]);
};
int main() {
  reading();
  if (st[1] == '0') {
    printf("NO");
    exit(0);
  }
  chuli();
  if (ans == 0)
    printf("NO");
  else
    print();
  return 0;
}
