Why my code is getting NZEC run time error?
<p><a href="https://www.spoj.pl/problems/ORDERS/" rel="nofollow">Question source: SPOJ.. ORDERS</a></p>

<pre><code>def swap(ary,idx1,idx2):
    tmp = ary[idx1]
    ary[idx1] = ary[idx2]
    ary[idx2] = tmp

def mkranks(size):
    tmp = []
    for i in range(1, size + 1):
        tmp = tmp + [i]
    return tmp

def permutations(ordered, movements):
    size = len(ordered)
    for i in range(1, size): # The leftmost one never moves
        for j in range(0, int(movements[i])):
            swap(ordered, i-j, i-j-1)
    return ordered

numberofcases = input()
for i in range(0, numberofcases):
    sizeofcase = input()
    tmp = raw_input()
    movements = ""
    for i in range(0, len(tmp)):
        if i % 2 != 1:
            movements = movements + tmp[i]
    ordered = mkranks(sizeofcase)
    ordered = permutations(ordered, movements)
    output = ""
    for i in range(0, sizeofcase - 1):
        output = output + str(ordered[i]) + " "
    output = output + str(ordered[sizeofcase - 1])
    print output
</code></pre>
