#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const int MAXN = 100;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  while (cin >> s) {
    int sz = s.size();
    unsigned long long a, b;
    cin >> a >> b;
    map<int, int> pos;
    unsigned long long mod = 0;
    for (int(i) = (0); (i) < (sz); ++(i)) {
      mod = (((mod % a) * (10 % a)) % a) + ((s[i] - '0') % a);
      mod %= a;
      if (mod == 0) pos[i]++;
    }
    mod = 0;
    unsigned long long ten = 1 % b;
    for (int i = sz - 1; i >= 1; i--) {
      mod = ((((s[i] - '0') % b) * (ten % b)) % b) + (mod % b);
      mod %= b;
      ten = (ten % b) * (10 % b);
      ten %= b;
      if (mod == 0 && s[i] != '0') pos[i - 1]++;
    }
    bool ok = false;
    for (map<int, int>::iterator p = pos.begin(); p != pos.end(); p++) {
      if (p->second > 1) {
        ok = true;
        cout << "YES" << endl;
        cout << s.substr(0, p->first + 1) << endl
             << s.substr(p->first + 1, sz - p->first + 1) << endl;
        break;
      }
    }
    if (!ok) {
      cout << "NO" << endl;
    }
  }
  return 0;
}
