import java.util.*;
import java.io.*;

class deck {
    public static void main(String[] args) throws Exception{
        Scanner in = new Scanner(new File("deck.in"));
        PrintWriter out = new PrintWriter(new File("deck.out"));

        String s = in.next();
        int len = s.length();
        char[] ch = s.toCharArray(), res = new char[len];

        Arrays.fill(res,'0');
        int[] a = new int[len];
        for(int i = 0; i < len; i++){
           a[i] = in.nextInt();
        }

        int n = 0;
        for(int i = 0; i < len; i++){
           for(int j = n ; j > a[i] ; j--)
             res[j] = res[j - 1];
           res[a[i]] = ch[i];
           n++;
        }
        for(int  i = 0; i < len; i++)
          out.print(res[i]);
        in.close();
        out.close();
    }
}
