#include <bits/stdc++.h>
using namespace std;
bool sortin(const pair<long long int, long long int> &e,
            const pair<long long int, long long int> &f) {
  return (e.first < f.first);
}
bool POT(long long int x) { return x && (!(x & (x - 1))); }
long long int a, b, c, i, j, k, l, m, n, p, q, r, x, y, z, ts, mn = 10e17,
                                                               mod = 10e8 + 7;
long long int ar[1000002], br[1000002], xr[1000002];
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  };
  string s;
  cin >> s >> a >> b;
  n = s.size();
  p = 1;
  for (long long int i = n - 1; i >= 0; i--) {
    xr[i] = ((s[i] - '0') * p + xr[i + 1]) % b;
    p = (p * 10) % b;
  }
  xr[n] = 1;
  p = 0;
  for (long long int i = 0; i <= n - 2; i++) {
    p = (p * 10 + s[i] - '0') % a;
    if (p == 0 and xr[i + 1] == 0 and s[i + 1] != '0') {
      cout << "YES";
      cout << endl;
      cout << s.substr(0, i + 1);
      cout << endl;
      cout << s.substr(i + 1, n - i - 1);
      return 0;
    }
  }
  cout << "NO";
}
