function y=backward_solve(i)

	rows=size(i,1);
	columns=size(i,2);
	c=0*ones (rows*columns, rows*columns); # initialise c matrix as NULL of order (rows*columns)*(rows*columns)
	for j=1:rows*columns
		if(rem(j,rows)==0)
			b=[j-rows j-1 j j+rows];
		elseif(rem(j,rows)==1)
			b=[j-rows j j+1 j+rows];		# vector b stores the switch numbers which will be toggled by pressing the switch x;
		else
			b=[j-rows j-1 j j+1 j+rows];
		endif
		for k=1:length(b)
			if(b(k)>0 && b(k)<rows*columns+1)
				c(j,b(k))=1;					# in matrix c, c(i,j)=1 iff button i is toggled on pressing button j
			endif
		endfor
	endfor
	
	initial=i(:);			# converts initial matrix i of order 3*3 into order 9*1
	
	x=det(c);
	action=-x*inverse(c)*initial;	#computes the action matrix using matrix operations
	w=int32(action);				#round off the action matrix into integer
	y=0*ones (rows, columns);		#initialise c matrix as NULL of order rows*columns
	for i=1:rows*columns
		y(i)=mod(w(i),2);			# takes remainder with 2
	endfor
	return;

endfunction