$chars = %w(1 2 3 4 5 6 7 8 9 0 + - * & | ^)

def check_valid(e)
	return false if e =~ /\b0\d+\b/
	return false if e =~ /[*+\-&|^]{2,}/
	return false if e =~ /(?<![)\d])[*+\-&|^]\d/
	begin
		eval e
		return true
	rescue SyntaxError
		return false
	end
end

def max_min(n, e, lb, ub)
	return eval(e) if n == 0
	(0..e.size).each do |i|
		l = (i == 0 ? "" : e[0..i-1])
		r = e[i..-1]
		$chars.each do |k|
			s = l + k + r
			break unless check_valid(s)
			mm = min_max(n-1, s, lb, ub)
			lb = mm if mm > lb
			return ub if lb >= ub
		end
	end
	if e.size > 1
		(0..e.size-1).each do |i|
			s = e.dup
			s.slice!(i)
			next unless check_valid(s)
			mm = min_max(n-1, s, lb, ub)
			lb = mm if mm > lb
			return ub if lb >= ub
		end
	end
	lb
end

def min_max(n, e, lb, ub)
	return eval(e) if n == 0
	(0..e.size).each do |i|
		l = (i == 0 ? "" : e[0..i-1])
		r = e[i..-1]
		$chars.each do |k|
			s = l + k + r
			break unless check_valid(s)
			mm = max_min(n-1, s, lb, ub)
			ub = mm if mm < ub
			return lb if ub <= lb
		end
	end
	if e.size > 1
		(0..e.size-1).each do |i|
			s = e.dup
			s.slice!(i)
			next unless check_valid(s)
			mm = max_min(n-1, s, lb, ub)
			ub = mm if mm < ub
			return lb if ub <= lb
		end
	end
	ub
end

loop do
	n, e = gets.split
	n = n.to_i
	break if n == 0
	puts max_min(n, e.chomp, -Float::INFINITY, Float::INFINITY)	
end