#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    string s;
    cin >> s;
    long long int a, b;
    cin >> a >> b;
    long long int n = s.length();
    vector<long long int> v1(n, -1), v2(n, -1);
    long long int x = 0;
    for (long long int i = 0; i < n; i++) {
      if (i == 0) {
        v1[i] = (s[i] - '0') % a;
        continue;
      }
      v1[i] = (v1[i - 1] * 10 + (s[i] - '0')) % a;
    }
    long long int base = 1;
    for (int i = n - 1; i >= 0; i--) {
      if (i == n - 1) {
        v2[i] = (s[i] - '0') % b;
      } else
        v2[i] = ((s[i] - '0') * base + v2[i + 1]) % b;
      base = (base * 10) % b;
    }
    long long int index = -1;
    for (long long int i = 0; i < n - 1; i++) {
      if (v1[i] == 0 && v2[i + 1] == 0 && s[i + 1] != '0') {
        index = i;
        break;
      }
    }
    if (index == -1)
      cout << "NO" << endl;
    else {
      cout << "YES" << endl;
      cout << s.substr(0, index + 1) << endl
           << s.substr(index + 1, n - index - 1);
    }
  }
  return 0;
}
