#include <bits/stdc++.h>
using namespace std;
char s[1000005];
int a, b, ls;
int kalana[1000005];
int kalanb[1000005];
char ola[1000005];
char olb[1000005];
int main() {
  scanf(" %s %d %d", s + 1, &a, &b);
  ls = strlen(s + 1);
  for (int i = 1; i <= ls; i++) {
    kalana[i] = (kalana[i - 1] * 10 + s[i] - '0') % a;
  }
  int on = 1;
  for (int i = ls; i >= 1; i--) {
    kalanb[i] = (kalanb[i + 1] + (s[i] - '0') * on) % b;
    on = (on * 10) % b;
  }
  int sifira = 1;
  for (int i = 1; i < ls; i++) {
    if (s[i] != '0') sifira = 0;
    if (!sifira && kalana[i] == 0) ola[i] = 1;
  }
  int sifirb = 1;
  for (int i = ls; i >= 2; i--) {
    if (s[i] != '0') sifirb = 0;
    if (!sifirb && kalanb[i] == 0) olb[i] = 1;
  }
  for (int i = 1; i < ls; i++) {
    if (ola[i] && olb[i + 1] && s[i + 1] != '0') {
      printf("YES\n");
      for (int j = 1; j <= ls; j++) {
        if (j == i + 1) printf("\n");
        printf("%c", s[j]);
      }
      getchar();
      getchar();
      getchar();
      return 0;
    }
  }
  printf("NO");
  getchar();
  getchar();
  getchar();
  return 0;
}
