#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000;
string s;
long long int a, b;
bool left_way[MAXN + 10] = {false};
bool ok = false;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  cin >> a >> b;
  if (s[0] == '0') {
    cout << "NO" << endl;
    return 0;
  }
  long long int curr_num = 0;
  for (long long int i = 0; i < (s.size()); i++) {
    curr_num = ((int)(s[i] - '0') + (1LL * 10 * curr_num) % a) % a;
    if (curr_num == 0) {
      left_way[i + 1] = true;
    }
  }
  curr_num = 0;
  long long int curr_pow = 1;
  long long int req_index;
  for (long long int i = (s.size() - 1); i >= (0); i--) {
    curr_pow = (1LL * curr_pow * 10) % b;
    curr_num = (curr_num + (1LL * curr_pow * (1LL * (s[i] - '0'))) % b) % b;
    if (curr_num == 0 and s[i] != '0' and left_way[i]) {
      req_index = i;
      ok = true;
      break;
    }
  }
  if (ok) {
    cout << "YES" << endl;
    for (long long int i = (0); i <= (req_index - 1); i++) {
      cout << s[i];
    }
    cout << endl;
    for (long long int i = (req_index); i <= (s.size() - 1); i++) {
      cout << s[i];
    }
    cout << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
