Build query matrix
temp = [ 1 , 1 , 2 , 1 , 4 , 5 , 2 , 1 , 2 , 2 , 1 , 3 , 2 , 3 , 4 ] NEW_LINE query = [ [ 0 for i in range ( 3 ) ] for j in range ( 6 ) ] NEW_LINE j = 0 NEW_LINE for i in range ( 1 , m + 1 ) : NEW_LINE INDENT query [ i ] [ 0 ] = temp [ j ] NEW_LINE j += 1 NEW_LINE query [ i ] [ 1 ] = temp [ j ] NEW_LINE j += 1 NEW_LINE query [ i ] [ 2 ] = temp [ j ] NEW_LINE j += 1 NEW_LINE DEDENT