#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e6 + 10;
char ch[N];
int n, x, y, temp = 1;
int a[N], b[N];
signed main() {
scanf("%s", ch + 1);
cin >> x >> y;
if(ch[1] == '0') {
cout << "NO\n";
return 0;
}
n = strlen(ch + 1);
for (int i = 1; i <= n; i++) a[i] = (a[i - 1] * 10 + ch[i] - '0') % x;
for (int i = n; i >= 1; i--) b[i] = (b[i + 1] + temp * (ch[i] - '0')) % y,temp = temp * 10 % y;
for (int i = 1; i < n; i++)
if (a[i] == 0 && b[i] == 0) {
cout << "YES\n";
for (int j = 1; j <= i; j++) cout << ch[j];
cout << endl;
for (int j = i + 1; j <= n; j++) cout << ch[j];
return 0;
}
cout << "NO\n";
}