#include <bits/stdc++.h>
using namespace std;
char str[1000010];
long long int i, j, k, l, a, b, pre[1000010], suff[1000010], temp;
int main() {
  string s;
  cin >> s;
  cin >> a >> b;
  l = s.length();
  for (i = 1; i <= l; i++) str[i] = s[i - 1];
  pre[1] = (str[1] - '0') % a;
  for (i = 2; i <= l; i++) pre[i] = (pre[i - 1] * 10 + (str[i] - '0')) % a;
  suff[l] = (str[l] - '0') % b;
  temp = 1;
  for (i = l - 1; i >= 1; i--) {
    temp = (temp * 10) % b;
    suff[i] = ((str[i] - '0') * temp + suff[i + 1]) % b;
  }
  for (i = 1; i <= l; i++) {
    if (str[i] != '0') {
      j = i;
      break;
    }
  }
  int f = 0;
  for (i = j; i <= l - 1; i++) {
    if (pre[i] == 0 && suff[i + 1] == 0 && str[i + 1] != '0') {
      f = 1;
      break;
    }
  }
  if (f) {
    cout << "YES" << endl;
    for (j = 1; j <= i; j++) printf("%c", str[j]);
    cout << endl;
    for (j = i + 1; j <= l; j++) printf("%c", str[j]);
  } else {
    cout << "NO";
  }
  return 0;
}
