#include <bits/stdc++.h>
using namespace std;
int v(int ind, string& str) { return str[ind] - '0'; }
int pw(int n) {
  int ret = 1;
  for (int i = 0; i < n; i++) ret *= 10;
  return ret;
}
vector<int> av, bv;
void printVec(vector<int>& vec) {
  for (int i = 0; i < vec.size(); i++) printf("%d ", vec[i]);
  printf("\n");
  return;
}
int main() {
  string str;
  int a, b;
  cin >> str >> a >> b;
  int n = str.size();
  int ls = 0;
  int m10;
  for (int i = 0; i < str.size(); i++) {
    ls = ((ls * 10 % a) % a + v(i, str) % a) % a;
    if (ls == 0) {
      av.push_back(i);
    }
  }
  ls = 0;
  m10 = 1 % b;
  for (int j = str.size() - 1; j >= 0; j--) {
    ls = (ls + (v(j, str) % b * m10)) % b;
    m10 = (m10 * 10 % b) % b;
    if (ls == 0) {
      bv.push_back(j);
    }
  }
  int s, e, mid, found, tar;
  for (int i = 0; i < av.size(); i++) {
    if (av[i] != str.size() - 1 && str[av[i] + 1] != '0') {
      s = 0, e = bv.size() - 1, found = 0;
      tar = av[i] + 1;
      while (s <= e) {
        mid = (s + e) / 2;
        if (bv[mid] > tar) {
          s = mid + 1;
        } else if (bv[mid] == tar) {
          found = true;
          s = mid + 1;
        } else {
          e = mid - 1;
        }
      }
      if (found == true) {
        printf("YES\n");
        for (int i = 0; i < tar; i++) {
          printf("%c", str[i]);
        }
        printf("\n");
        for (int i = tar; i < str.size(); i++) {
          printf("%c", str[i]);
        }
        printf("\n");
        return 0;
      }
    }
  }
  printf("NO\n");
}
