#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s;
  int a, b;
  cin >> s;
  cin >> a >> b;
  int n = s.size();
  int posa[s.size() + 1];
  int suma[s.size() + 1];
  int sumb[s.size() + 1];
  memset(suma, 0, sizeof(suma));
  memset(sumb, 0, sizeof(sumb));
  memset(posa, 0, sizeof(posa));
  int sum = 0;
  for (int i = 0; i < s.size() - 1; i++) {
    sum = (sum * 10 + s[i] - '0') % a;
    suma[i] = sum;
    if (s[i + 1] != '0' && sum == 0) {
      posa[i] = 1;
    }
  }
  sum = 0;
  int ans = -1;
  for (int j = s.size() - 1, p = 1; j >= 1; j--, p = (p * 10) % b) {
    if (j != s.size() - 1)
      sum = (sum + (s[j] - '0') * p) % b;
    else
      sum = (s[j] - '0') % b;
    sumb[j] = sum;
    if (posa[j - 1] == 1 && sum == 0) {
      ans = j - 1;
    }
  }
  if (ans == -1)
    cout << "NO";
  else {
    cout << "YES" << endl;
    int i;
    for (i = 0; i <= ans; i++) cout << s[i];
    cout << endl;
    for (i; i < s.size(); i++) cout << s[i];
  }
  cout << endl;
}
