#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
char str[maxn];
long long A[maxn], B[maxn], div1, div2;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  while (cin >> str >> div1 >> div2) {
    long long pre = 0, p = 1;
    const int len = strlen(str);
    for (int i = 0; i < len; i++) {
      pre = pre * 10 + str[i] - '0';
      A[i] = (pre %= div1);
    }
    pre = 0;
    for (int i = len - 1; ~i; i--) {
      pre = pre + (str[i] - '0') * p;
      p = p * 10 % div2;
      B[i] = (pre %= div2);
    }
    int ans = -1;
    for (int i = 0; i < len - 1; i++) {
      if (A[i] == 0 && B[i + 1] == 0 && str[i + 1] != '0') {
        ans = i;
        break;
      }
    }
    if (ans == -1)
      cout << "NO" << endl;
    else {
      cout << "YES" << endl;
      for (int i = 0; i <= ans; i++) cout << str[i];
      cout << endl;
      for (int i = ans + 1; i < len; i++) cout << str[i];
      cout << endl;
    }
  }
  return 0;
}
