// Arup Guha
// 11/3/2018
// Solution to 2018 D2 Problem: Random Index Vectors

import java.util.*;

public class riv {
	
	public static void main(String[] args) {
		
		// Read in v1.
		Scanner stdin = new Scanner(System.in);
		long n = stdin.nextLong();
		long k = stdin.nextLong();
		vect v1 = new vect(n);
		int m = stdin.nextInt();
		for (int i=0; i<m; i++) {
			long tmp = stdin.nextLong();
			v1.add(tmp);
		}
		
		// And v2...
		vect v2 = new vect(n);
		m = stdin.nextInt();
		for (int i=0; i<m; i++) {
			long tmp = stdin.nextLong();
			v2.add(tmp);
		}		
		
		// This is what they want.
		vect sum = v1.sum(v2);
		System.out.println(sum);
		vect prod = v1.mult(v2);
		System.out.println(prod);
		vect r1 = v1.rot(k);
		System.out.println(r1);
		vect r2 = v2.rot(k);
		System.out.println(r2);
		
	}

}

class vect {
	
	public long n;
	public ArrayList<Long> list;
	
	public vect(long myn) {
		n = myn;
		list = new ArrayList<Long>();
	}
	
	public vect(ArrayList<Long> x, long myn) {
		n = myn;
		list = x;
	}
	
	public void add(long x) {
		list.add(x);
	}
	
	public vect sum(vect other) {
		ArrayList<Long> res = new ArrayList<Long>();
		
		int i = 0 , j = 0;
		
		// Go through both.
		while (i < this.list.size() || j < other.list.size()) {
			
			// Avoid AOOB...
			if (j == other.list.size())
				res.add(this.list.get(i++));
			else if (i == this.list.size())
				res.add(other.list.get(j++));
			
			// Only term from this.
			else if (Math.abs(this.list.get(i)) < Math.abs(other.list.get(j)))
				res.add(this.list.get(i++));
			
			// Only list from other.
			else if (Math.abs(other.list.get(j)) < Math.abs(this.list.get(i)))
				res.add(other.list.get(j++));
			
			// Three cases, combining like terms.
			else {
				
				if (this.list.get(i).equals(other.list.get(j)))
					res.add(this.list.get(i));
				i++;
				j++;
			}
		}
		
		// Here is what we get when we add.
		return new vect(res, Math.max(this.n, other.n));
	}
	
	public vect mult(vect other) {
		ArrayList<Long> res = new ArrayList<Long>();
		
		int i = 0 , j = 0;
		
		// Go through both.
		while (i < this.list.size() || j < other.list.size()) {
			
			if (i == this.list.size()) break;
			if (j == other.list.size()) break;
			
			// zero term...
			if (Math.abs(this.list.get(i)) < Math.abs(other.list.get(j))) i++;
			
			// another zero term...
			else if (Math.abs(this.list.get(i)) > Math.abs(other.list.get(j))) j++;
			
			// Only term from this.
			else if (Math.abs(this.list.get(i)) == (Math.abs(other.list.get(j)))) {
				//System.out.println("gets here "+this.list.get(i)+" "+other.list.get(j));
				if (!this.list.get(i).equals(other.list.get(j)))
					res.add(-Math.abs(this.list.get(i)));
				else
					res.add(Math.abs(this.list.get(i)));
				i++;
				j++;
			}
		}
		
		// Here is what we get when we add.
		return new vect(res, Math.max(this.n, other.n));
	}	

	// Returns a new vector rotated by k.
	public vect rot(long k) {
		
		ArrayList<Long> res = new ArrayList<Long>();
		
		if (this.list.size() == 0) return new vect(res, this.n);
		
		// Default.
		int start = 0;
		
		// Starts in middle; find start.
		if (k < Math.abs(this.list.get(list.size()-1))) {
			while (Math.abs(this.list.get(start)) <= k) start++;
		}
		
		for (int i=start; i<start+this.list.size(); i++) {
			int sign = this.list.get(i%this.list.size()) > 0 ? 1 : -1;
			long abs = Math.abs(this.list.get(i%this.list.size()));
			abs -= k;
			if (abs <= 0) abs += n;
			res.add(sign*abs);
		}
		
		return new vect(res, this.n);
	}
	
	public String toString() {
		String res = "" + list.size();
		for (int i=0; i<list.size(); i++)
			res = res + " " + list.get(i);
		return res;
	}
}
