#include <bits/stdc++.h>
using namespace std;
int const siz = 1e9, bound = 1e5, mod = siz + 7;
long long const cnt = 5e18;
string s;
long long a, b;
set<int> idx;
int main() {
  ios::sync_with_stdio(0);
  cin >> s;
  cin >> a >> b;
  long long md = 0;
  for (int(i) = 0; (i) < ((int)s.size()); (i)++) {
    md = (md * 10 + s[i] - '0') % a;
    if (md == 0) {
      if (i + 1 < s.size() && s[i + 1] == '0')
        while (i + 1 < s.size() && s[i + 1] == '0') i++;
      idx.insert(i + 1);
    }
  }
  md = 0;
  long long rev = 1;
  for (int i = s.size() - 1; i > -1; i--) {
    md = (md + (s[i] - '0') * rev) % b;
    if (md == 0 && s[i] != '0') {
      if (!idx.insert(i).second) {
        cout << "YES\n";
        cout << s.substr(0, i) << endl << s.substr(i, s.size()) << endl;
        return 0;
      }
    }
    rev = rev * 10 % b;
  }
  cout << "NO\n";
  return 0;
}
