private List<Gate> getMGates(int startOfE, int startOfA, int startOfB, int m1,
			int startOfMComputation, int startOfM) {
		List<Gate> res = new ArrayList<Gate>();

		//Construct the AND and XOR gates
		int priorOutput = 0;
		int m1Squared = m1 * m1;
		int[] aConvolutedE = new int[m1];
		for (int j = 0; j < m1; j++) {
			int index = 0;
			for (int i = 0; i < m1; i++) {
				int leftWire = startOfA + i;
				int rightWire = startOfE + ((i + j) % m1);
				index = m1 * j + i;
				int outputWire = startOfMComputation + index;
				Gate andGate = new Gate("2 1 "+ leftWire + " " + rightWire +
						" " + outputWire + " 0001", InputGateType.FAIRPLAY);
				res.add(andGate);
				/*****************************************************/
				if (i == m1 - 1) {
					continue;
				}
				index = j * m1 + i;
				if (i == 0) {
					leftWire = startOfMComputation + index;
					rightWire = startOfMComputation + index + 1;
				} else {
					leftWire = startOfMComputation + index + 1;
					rightWire = priorOutput;
				}
				index = index - j;

				outputWire = priorOutput = 
						startOfMComputation + index + m1Squared;
				Gate orGate = new Gate("2 1 "+ leftWire + " " + rightWire +
						" " + outputWire + " 0110", InputGateType.FAIRPLAY);
				res.add(orGate);

			}
			aConvolutedE[j] = startOfMComputation + index + m1Squared - 1;
		}
		
		//Construct final XOR gates 
		for (int i = 0; i < m1; i++) {
			int leftWire = aConvolutedE[i];
			int rightWire = startOfB + i;
			int outputWire = startOfM + i;
			Gate g = new Gate("2 1 "+ leftWire + " " + rightWire +
					" " + outputWire + " 0110", InputGateType.FAIRPLAY);
			res.add(g);
		}
		return res;
	}