// Arup Guha
// 3/21/2022
// Solution to Spring 2022 COP 3503 Program #5: Polynomial Multiplication
 
import java.util.*;

public class poly {
	
	// Instance variables of the polynomial.
	private long[] coeff;
	private int length;
	
	// Constructor, makes sure degree is a power of 2 minus 1.
	public poly(long[] vals) {
		length = 1;
		while (length < vals.length) length <<= 1;
		coeff = new long[length];
		for (int i=0; i<vals.length; i++)
			coeff[i] = vals[i];
	}
	
	// Prints this object from the leadTerm on, one coefficient per line (as per the problem specification).
	public void print(int leadTerm) {
		StringBuffer sb = new StringBuffer();
		for (int i=leadTerm; i>=0; i--) 
			sb.append(coeff[i]+"\n");
		System.out.print(sb);
	}

	// Returns this poly plus other,
	public poly add(poly other) {
		long[] res = new long[Math.max(length, other.length)];
		for (int i=0; i<res.length; i++) {
			if (i<length) res[i] += coeff[i];
			if (i<other.length) res[i] += other.coeff[i];
		}
		return new poly(res);
	}
	
	// Returns this poly minus other.
	public poly sub(poly other) {
		long[] res = new long[Math.max(length, other.length)];
		for (int i=0; i<res.length; i++) {
			if (i<length) res[i] += coeff[i];
			if (i<other.length) res[i] -= other.coeff[i];
		}
		return new poly(res);
	}
	
	// Grade school method of polynomial multiplication.
	public poly multSlow(poly other) {
		
		// One term bigger than it needs to be.
		long[] res = new long[length+other.length];
		
		// Just add each term into the appropriate exponent.
		for (int i=0; i<length; i++)
			for (int j=0; j<other.length; j++)
				res[i+j] += (coeff[i]*other.coeff[j]);
			
		// Here is our result.
		return new poly(res);
	}
	
	// This is for my testing purposes.
	public boolean equal(poly other) {
		if (length != other.length) return false;
		for (int i=0; i<length; i++)
			if (coeff[i] != other.coeff[i])
				return false;
		return true;
	}
	
	// Pre-condition: this and other are polymomials of degree 2 to a power of n minus 1.
	// Post-condition: The product of this and other is returned in a polynomial of degree 2 to the power (n+1) minus 1.
	public poly mult(poly other) {
	
		// This base case seemed to produce the fastest code.
		if (length <= (1<<5)) return multSlow(other);
		
		// Extract out 4 pieces.
		poly aLeft = getLeft();
		poly aRight = getRight();
		poly bLeft = other.getLeft();
		poly bRight = other.getRight();
		
		// Get sums of both halves for both polynomials.
		poly sumA = aLeft.add(aRight);
		poly sumB = bLeft.add(bRight);
		
		// Three recursive products.
		poly left = aLeft.mult(bLeft);
		poly right = aRight.mult(bRight);
		poly mid = sumA.mult(sumB);
		
		// Subtract out left and right subproducts to get the appropriate "middle" piece.
		mid = mid.sub(left);
		mid = mid.sub(right);
		
		// Add in each component.
		long[] res = new long[2*length];
		
		// Least significant goes in the same place.
		for (int i=0; i<right.length; i++)
			res[i] += right.coeff[i];
		
		// Left (most significant) is shifted by length of right.
		for (int i=0; i<left.length; i++)
			res[i+right.length] += left.coeff[i];
		
		// Middle terms are shifted half as much.
		for (int i=0; i<mid.length; i++)
			res[i+mid.length/2] += mid.coeff[i];
		
		// Return the result as a poly.
		return new poly(res);
	}
	
	// Returns the left half (most significant terms) of this poly in a new poly.
	private poly getLeft() {
		long[] res = new long[length/2];
		for (int i=length/2; i<length; i++)
			res[i-length/2] = coeff[i];
		return new poly(res);
	}
	
	// Returns the right half (least significant terms) of this poly in a new poly.
	private poly getRight() {
		long[] res = new long[length/2];
		for (int i=0; i<length/2; i++)
			res[i] = coeff[i];
		return new poly(res);
	}

	// Runs the program.
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		int pow = stdin.nextInt();
		
		// Read the first poly and form it.
		long[] tmp = new long[1<<pow];
		for (int i=tmp.length-1; i>=0; i--)
			tmp[i] = stdin.nextLong();
		poly firstPoly = new poly(tmp);
		
		// And the second.
		tmp = new long[1<<pow];
		for (int i=tmp.length-1; i>=0; i--)
			tmp[i] = stdin.nextLong();
		poly secondPoly = new poly(tmp);
		
		// Multiply and print.
		poly res = firstPoly.mult(secondPoly);
		res.print((1<<(pow+1))-2);
	
	}
}