#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
string s;
long long a, b;
long long v[N], pre[N], suf[N];
int32_t main() {
  cin >> s >> a >> b;
  long long n = s.size();
  for (long long i = 1; i <= n; i++) v[i] = s[i - 1] - '0';
  for (long long i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] * 10 + v[i];
    pre[i] %= a;
  }
  long long curpow = 1;
  for (long long i = n; i >= 1; i--) {
    suf[i] = v[i] * curpow + suf[i + 1];
    curpow *= 10;
    curpow %= b;
    suf[i] %= b;
  }
  long long check = 0, ind;
  for (long long i = 1; i < n; i++) {
    if (pre[i] == 0 && suf[i + 1] == 0 && v[i + 1] != 0) {
      ind = i;
      check = 1;
    }
  }
  if (check) {
    cout << "YES"
         << "\n";
    for (long long i = 1; i <= ind; i++) {
      cout << v[i];
    }
    cout << "\n";
    for (long long i = ind + 1; i <= n; i++) {
      cout << v[i];
    }
  } else
    cout << "NO";
}
