#include <bits/stdc++.h>
using namespace std;
inline long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
inline long long int fast_pow(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
inline bool isPrime(long long int a) {
  for (long long int i = 2; i * i <= a; i++)
    if (a % i == 0) return 0;
  return 1;
}
const int N = 1e6 + 5;
string s;
long long int a, b, pref[N], suff[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> s >> a >> b;
  long long int c = 0, mul = 1;
  for (int i = 0; i < s.size(); i++) {
    c = c * 10 + (s[i] - '0');
    if (c % a)
      pref[i] = 0;
    else
      pref[i] = 1;
    c %= a;
  }
  c = 0;
  for (int i = s.size() - 1; i >= 0; i--) {
    c += (s[i] - '0') * mul;
    mul *= 10;
    mul %= b;
    if (c % b)
      suff[i] = 0;
    else
      suff[i] = 1;
    c %= b;
  }
  for (int i = s.size() - 2; i >= 0; i--) {
    if (!(i == s.size() - 2 && s[s.size() - 1] == '0') && pref[i] &&
        suff[i + 1]) {
      cout << "YES\n";
      for (int j = 0; j <= i; j++) cout << s[j];
      cout << '\n';
      for (int j = i + 1; j < s.size(); j++) cout << s[j];
      cout << '\n';
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}
