#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define io_speed ios_base::sync_with_stdio(0);cin.tie(0)
string s;
int a,b,vis[];
int main(){
io_speed;
cin>>s;
cin>>a>>b;
int base=,ans=,len = s.size();
memset(vis,,sizeof(vis));
for(int i=len-;i>;i--){
ans = ( ans + (s[i] - '')*base ) % b;
vis[i] = ans;
base = base*%b;
}
ans=;
for(int i=;i<len-;i++){
ans = ( ans* + s[i]-'' ) % a;
if( ans== && vis[i+]== && s[i+]!='' ){
cout<<"YES\n";
cout<<s.substr(,i+)<<endl;
cout<<s.substr(i+,len-i-)<<endl;
return ;
}
}
puts("NO");
return ;
}