/**
 * Created by IntelliJ IDEA.
 * User: m09bma
 * Date: 28.10.2009
 * Time: 18:46:05
 * To change this template use File | Settings | File Templates.
 */
 import java.util.*;
import java.io.*;
public class Cards {

public static void main (String[] args) throws Exception{
    Scanner in = new Scanner (new File ("deck.in"));
    PrintWriter out =  new PrintWriter ("deck.out");
    String s1 =in.nextLine();
    char [] c1 = s1.toCharArray();
    int[] a = new int[ c1.length ];
    for(int i = 0; i < c1.length; i++)
        a[i] = in.nextInt();
    char[] s2 = new char[ c1.length ];
    for (int i = 0 ; i < c1.length; i++){
        int j = a[i];
        for(int k = i - 1; k >= j; k--)
        {
           s2[k+1] = s2[k];
        }
        s2[j] = c1[i];
    }
    for (int g = 0; g < c1.length; g++){
      out.print (s2[g]);
    }
    out.close();
}
}
