#include <bits/stdc++.h>
using namespace std;
int A[1111111], B[1111111];
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  getline(cin, s);
  int a, b;
  cin >> a >> b;
  memset(A, 0, sizeof(A));
  int n = s.size();
  for (int i = 1; i <= n; ++i) A[i] = s[i - 1] - '0';
  memset(B, 0, sizeof(B));
  int power = 1 % b;
  B[n + 1] = 0;
  for (int i = n; i >= 1; --i) {
    int q = A[i] * power;
    B[i] = (B[i + 1] + q) % b;
    power = (power * 10) % b;
  }
  int cur = 0;
  for (int i = 1; i < n; ++i) {
    cur = (cur * 10 + A[i]) % a;
    if (A[i + 1] == 0) continue;
    if (cur == 0 && B[i + 1] == 0) {
      cout << "YES" << endl;
      for (int j = 1; j <= i; ++j) cout << A[j];
      cout << endl;
      for (int j = i + 1; j <= n; ++j) cout << A[j];
      cout << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
