function s = find_match(v,A,blksize,skip)

[nr,nc] = size(A);

level = v(1);

start = (level - 1)*blksize + 2;

if (nr + 1 < start)
    s = -1;

else
    if (nr > start)
	s = -1;
	for i = 1:nc,
	    diff = abs(A(start-1,i) - v(2));
	    if (diff <= skip) & (A(start,i) == 0) & (A(start-1,i) > 0)
		s = i;
		break;
	    end
	end
    else
	s = -1;
	for i = 1:nc,
	    diff = abs(A(start-1,i) - v(2));
	    if (diff <= skip) & (A(start-1,i) > 0)
		s = i;
		break;
	    end
	end
    end	
end
 
   
