Secret Message Pad
Difficulty: Hard

Hearing stories from the Oracle that a programmer named Neo may possibly be "The One", Trinity risks going into the Matrix to observe Neo. While in the Matrix, her communications are intercepted and Trinity is almost caught by Agent Smith and two other agents. Safely back in the hovercraft Nebuchadnezzar, Trinity decides to add another level of encryption to her communication using a "one-time pad". The idea is that given a sequence of numbers (a pad), any message can be proven to be securely encrypted if each character in the string is encoded by a number from the pad, if each number from the pad is only used once. Trinity decides to use the one-time pad to encrypt her messages by shifting each letter in the message by k positions later in the alphabet, where k is determined by the one-time pad. Shifts occur in alphabetical order, between the letters “a” and “z”. If a letter is shifted past “z”, it starts back at “a” and continues shifting. For example, shifting each letter by k = 2, the word “car” is transformed into “ect”, while the word “yaz” is shifted to “acb”.  

**Input format:**
The input will begin with the size of the one-time pad, followed by a sequence of numbers for the pad. The remaining input consists of a series of words to be encrypted using the keyword. The input will be terminated by a line containing only -1.
You may assume that the maximum size of the pad is 100 numbers, all numbers in the pad are between 0 and 25, and that all input will be lowercase letters.

**Output Format:**
For each word to be encrypted, output a line containing the encrypted word.


**Sample Input 1:**  
10  
1 2 3 4 5 4 3 2 1 0  
aaaaa zzzzz  
-1  

**Sample Output 1:**  
bcdef  
dcbaz

**Sample Input 2:**  
40  
1 5 2 21 3 8 4 25 11 9  
6 7 8 9 11 12 3 0 11 4  
14 21 9 0 1 3 12 7 2 11  
5 9 20 12 1 19 4 9 8 24  
humans make good batteries  
gnlr esrf  
-1  

**Sample Output 2:**  
izovqa  
qzvn  
mvwm  
mmwtpvwzb  
good  
luck 

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (C++):
    #include <stdlib.h>
    #include <iostream.h>
    #include <assert.h>
    #include "apstring.h"
    #include "apstring.cpp"

    //-----------------------------------------------------------------------
    //  main
    //-----------------------------------------------------------------------

    int main()
    {
	apstring key;
	apstring buf;
	int pad[100];      // max pad is 100 chars
	char code[100];    // store encrypted string
	int i,len,padsize,padindex;
	unsigned int c;

	cin >> padsize;
	padindex = 0;

	for (i = 0; i<padsize; i++) {  // read in pad
		cin >> pad[i];
		assert((pad[i] >= 0) && (pad[i] <= 25));
	}

	cin >> buf;
	while (buf != "-1") {  // look at each string

		len = buf.length();
		for (i = 0; i < len; i++) {
		        assert((buf[i] >= 'a') && (buf[i] <= 'z'));
			c = (unsigned int) (buf[i] + pad[padindex++]);
			if (c > (unsigned int) 'z')
				c -= 26;  // 26 letters
			code[i] = (char) c;
		}

		assert(i < 100);
		code[i] = '\0';
		cout << code << endl;  // print output
		cin >> buf;            // get next string
	 }
    }