#include <bits/stdc++.h>
using namespace std;
int p[1000010], q[1000010];
int main() {
  string s;
  cin >> s;
  int a, b;
  cin >> a >> b;
  int n = s.size();
  int re = 0;
  for (int i = 0; i < n; i++) {
    re = (re * 10 + (s[i] - '0')) % a;
    p[i] = re;
  }
  int po = 1;
  for (int i = n - 1; i >= 1; i--) {
    q[i] = ((s[i] - '0') * po + q[i + 1]) % b;
    po = po * 10 % b;
    if (!q[i] && !p[i - 1] && s[i] != '0') {
      cout << "YES\n";
      cout << s.substr(0, i) << "\n" << s.substr(i, n) << "\n";
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}
