#include <bits/stdc++.h>
using namespace std;
vector<long long int> cut;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    string s;
    cin >> s;
    long long a, b;
    cin >> a >> b;
    long long m = 0;
    long long I = 1;
    for (long long int i = 0; i < s.length(); i++) {
      m = m * 10 + (s[i] - '0');
      m = m % a;
      if (m == 0) {
        if (s[i + 1] != '0' && i + 1 < s.length()) cut.push_back(i + 1);
      }
    }
    if (cut.empty()) {
      cout << "NO";
      return 0;
    }
    I = s.length();
    long long t = 0;
    long long P = 1;
    m = 0;
    while (!cut.empty()) {
      for (long long i = I - 1; i >= cut.back(); i--) {
        m = m + (s[i] - '0') * P;
        m = m % b;
        P = (P * 10) % b;
      }
      I = cut.back();
      cut.pop_back();
      if (m == 0) {
        cout << "YES" << '\n';
        for (long long int k = 0; k < I; k++) cout << s[k];
        cout << "\n";
        for (long long int k = I; k < s.length(); k++) cout << s[k];
        return 0;
      }
    }
    cout << "NO";
  }
  return 0;
}
