#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[1000005];
  long long a, b, index = -1;
  cin >> s >> a >> b;
  long long res = 0;
  long long l = strlen(s);
  map<long long, bool> m;
  long long tmp = 10 % a;
  for (long long i = 0; i < l; i++) {
    res = res * tmp + ((s[i] - 48) % a);
    res = res % a;
    if (res == 0) m[i] = true;
    tmp = tmp % a;
  }
  res = 0;
  tmp = 1;
  long long d = 0;
  for (long long i = l - 1; i >= 0; i--) {
    res = res + ((s[i] - 48) % b) * tmp;
    tmp = tmp * (10 % b);
    res = res % b;
    tmp = tmp % b;
    if (res == 0) {
      if (m[i - 1] && s[i] != '0') {
        index = i;
        break;
      }
    }
  }
  if (index == -1 || s[index] == '0') {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    for (long long i = 0; i < index; i++) cout << s[i];
    cout << endl;
    for (long long i = index; i < l; i++) cout << s[i];
    cout << endl;
  }
}
