#include <iostream>
#include <cstring>
using namespace std;
int v[100100], n;
string A;
char s1[200000], s2[200000], sol[300];

string ToString(int x)
{
    string rez, rez2;
    rez.clear();
    rez2.clear();
    if(x == 0)
    {
        rez += "0";
        return rez;
    }
    while(x)
    {
        rez += (char)(x % 10 + '0');
        x /= 10;
    }
    int i;
    for(i = rez.size() - 1; i >= 0; --i)
        rez2 += rez[i];
    return rez2;
}

string ToHexa(int x, bool numar)
{
    string rez, rez2;
    rez.clear();
    rez2.clear();
    if(x == 0)
    {
        rez += "00";
        return rez;
    }
    while(x)
    {
        if(x % 16 < 10)
            rez += (char)(x % 16 + '0');
        else
            rez += (char)('A' + x % 16 - 10);
        x /= 16;
    }
    int i;
    if(numar)
        return rez;
    for(i = rez.size() - 1; i >= 0; --i)
        rez2 += rez[i];
    return rez2;
}

int main()
{
    //freopen("C.in", "r", stdin);
    cin.getline(s1, 200000);
    cin.getline(s2, 200000);
    int ns = strlen(s1), ms = strlen(s2);
    int i, j, k;
    for(i = 0; i < 256; ++i)
        sol[i] = '0';
    i = 0;
    while(i < ns && s1[i] != ',')
    {
        A += s1[i];
        i++;
    }
    while(i < ns)
    {
        if(s1[i] == ',')
        {
            i++;
            continue;
        }
        n++;
        while(i < ns && '0' <= s1[i] && s1[i] <= '9')
        {
            v[n] = v[n] * 10 + s1[i] - '0';
            i++;
        }
        v[n] *= 2;
    }
    ns = A.size();
    i = j = 0;
    k = 1;
    while(i < ns)
    {
        if(A[i] == ' ')
        {
            while(i < ns && A[i] == ' ')
                i++;
            while(j < ms && s2[j] == ' ')
                j++;
            continue;
        }
        if(A[i] == '%')
        {
            i++;
            if(A[i] == 'u')
            {
                int x = 0;
                while(j < ms && '0' <= s2[j] && s2[j] <= '9')
                {
                    x = x * 10 + s2[j] - '0';
                    j++;
                }
                string aux = ToHexa(x, true);
                while(aux.size() < 8)
                    aux += '0';
                for(int kk = v[k]; kk < v[k] + 8; kk += 2)
                {
                    sol[kk] = aux[kk - v[k] + 1];
                    sol[kk + 1] = aux[kk - v[k]];

                }
            }
            if(A[i] == 'x')
            {
                j += 2;
                int lg = 0;
                string aux;
                aux.clear();
                while(lg < 8 && j < ms && (('0' <= s2[j] && s2[j] <= '9') || ('A' <= s2[j] && s2[j] <= 'F')))
                {
                    aux += s2[j];
                    j++;
                    lg++;
                }
                if(lg % 2 == 1)
                {
                    sol[v[k]] = '0';
                    lg++;
                }
                for(int kk = v[k], jj = lg - 1; jj > 0; jj -= 2)
                {
                    sol[kk] = aux[jj - 1];
                    sol[kk + 1] = aux[jj];
                    kk += 2;
                }
            }
            if(A[i] == 's')
            {
                int kk = v[k];
                while(j < ms && s2[j] != ' ')
                {
                    string aux = ToHexa(s2[j], false);
                    sol[kk] = aux[0];
                    sol[kk + 1] = aux[1];
                    kk += 2;
                    j++;
                }
                sol[kk] = '0';
                sol[kk + 1] = '0';
            }
            if(A[i] == 'c')
            {
                int kk = v[k];
                string aux = ToHexa(s2[j], false);
                sol[kk] = aux[0];
                sol[kk + 1] = aux[1];
                kk += 2;
                j++;
            }
            i++;
            k++;
            continue;
        }
        i++;
        j++;
        continue;
    }
    for(i = 0; i < 256; ++i)
        cout << sol[i];
    cout << "\n";
    return 0;
}