public static void fun()
{
    String t1="",t2="";
   while(m>0 && n>0){
if(arr[m-1][n-1]==min(arr[m-1][n-1],arr[m][n-1],arr[m-1][n])){
t1=s1.charAt(m-1)+t1;
t2=s2.charAt(n-1)+t2;
m--;
n--;

}else if(arr[m][n-1]==min(arr[m-1][n-1],arr[m][n-1],arr[m-1][n])){
t1="-"+t1;
t2=s2.charAt(n-1)+t2;
n--;

}else if(arr[m-1][n]==min(arr[m-1][n-1],arr[m][n-1],arr[m-1][n])){
t2="-"+t2;
t1=s1.charAt(m-1)+t1;
m--;

}

}
if(m>0){
while(m>0){
t1=s1.charAt(m-1)+t1;
t2="-"+t2;
m--;
}
}else if(n>0){
while(n>0){
t2=s2.charAt(n-1)+t2;
t1="-"+t1;
n--;
}
} 


System.out.println(t1);
System.out.println(t2);

}