#include <bits/stdc++.h>
using namespace std;
char arr[1000006];
long long front[1000006] = {0};
long long back[1000006] = {0};
int main() {
  long long a, b;
  scanf("%s", arr);
  scanf("%lld", &a);
  scanf("%lld", &b);
  long long n = strlen(arr);
  if (n == 1) {
    printf("NO\n");
  } else {
    front[0] = (long long)(arr[0] - '0') % a;
    for (long long i = 1; i < n; i++) {
      front[i] = (front[i - 1] * 10 + (long long)(arr[i] - '0')) % a;
    }
    back[n - 1] = (long long)(arr[n - 1] - '0') % b;
    long long p = 1;
    for (long long i = n - 2; i >= 0; i--) {
      p = ((p % b) * (10 % b)) % b;
      back[i] =
          ((((long long)(arr[i] - '0') % b) * p) % b + back[i + 1] % b) % b;
    }
    long long flag = -1;
    for (long long i = 0; i < n - 1; i++) {
      if (front[i] == 0 && back[i + 1] == 0 && (arr[i + 1] - '0') != 0) {
        flag = i;
        break;
      }
    }
    if (flag >= 0) {
      printf("YES\n");
      for (long long i = 0; i <= flag; i++) {
        printf("%c", arr[i]);
      }
      printf("\n");
      for (long long i = flag + 1; i < n; i++) {
        printf("%c", arr[i]);
      }
      printf("\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
