import java.util.Scanner;
public class Main {
static Scanner sc=new Scanner(System.in);
static int key,len;
static String flagseq;
static int curMod;
public static void main(String[] args){
key=sc.nextInt();
len=sc.nextInt();
flagseq=sc.next();
curMod=0;
String num="";
String app="";
if(flagseq.charAt(0)=='1' && key==10){
System.out.println(-1);
return;
}
for(int i=0;i<len;i++){
curMod*=10;
curMod=curMod%key;
if(flagseq.charAt(i)=='0'){
if(curMod==0){
app="1";
}
else{
app="0";
}
}
else{
if(curMod==0){
if(num==""){
app=key+"";
}
else{
app="0";
}
}
else{
int temp=key;
temp-=curMod;
app=temp+"";
}
}
int newMod=curMod;
newMod+=Integer.parseInt(app);
newMod=newMod%key;
curMod=newMod;
num+=app;
}
System.out.println(num);
}
}