#define USE_ACLIBRARY 0 #if __has_include() #include #else #include #if __has_include() || USE_ACLIBRARY #include #endif #endif #define ov4(a, b, c, d, name, ...) name #define rep3(i, a, b, c) for (ll i = (a); i < ll(b); i += (c)) #define rep2(i, a, b) rep3(i, a, b, 1) #define rep1(i, n) rep2(i, 0, n) #define rep0(n) rep1(aaaaa, n) #define rep(...) ov4(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__) #define per(i, a, b) for (ll i = (a) - 1; i >= ll(b); i--) using ll = long long int; using ull = unsigned long long int; using pll = std::pair; using pil = std::pair; using pli = std::pair; using pii = std::pair; constexpr const ll INFL = 1ll << 60; using namespace std::literals; std::mt19937_64 rng{std::random_device()()}; template bool chmin(T& x, const T& val) { if (x > val) { x = val; return true; } else { return false; } } template bool chmin2(T& x, const T& val) { if (!(val < 0) and (x < 0 || x > val)) { x = val; return true; } else { return false; } } template bool chmax(T& x, const T& val) { if (x < val) { x = val; return true; } else { return false; } } ll isqrt(ll n) { assert(n >= 0); if (n == 0) return 0; uint32_t c = (std::bit_width(uint64_t(n)) - 1) / 2; ll a = 1; ll d = 0; for (int s = std::bit_width(c) - 1; s >= 0; s--) { ll e = d; d = c >> s; a = (a << (d - e - 1)) + (n >> (2 * c - e - d + 1)) / a; } return a - (a * a > n); } #if __has_include() || USE_ACLIBRARY template * = nullptr> std::ostream& operator<<(std::ostream& os, const mint& v) { return os << v.val(); } template * = nullptr> std::istream& operator>>(std::istream& is, mint& v) { int tmp; is >> tmp; v = tmp; return is; } template requires atcoder::internal::is_modint::value struct std::formatter : std::formatter { template auto format(const mint& x, FormatContext& context) const { return std::formatter::format(x.val(), context); } }; #endif template std::istream& operator>>(std::istream& is, std::pair& p) { return is >> p.first >> p.second; } template std::istream& operator>>(std::istream& is, std::tuple& tpl) { std::apply([&](auto&&... args) { (is >> ... >> args); }, tpl); return is; } template std::istream& operator>>(std::istream& is, std::vector& v) { for (T& x : v) is >> x; return is; } template std::ostream& operator<<(std::ostream& os, const std::vector& v) { for (size_t i = 0; i < v.size(); i++) os << v[i] << (i == v.size() - 1 ? "" : " "); return os; } template std::vector make_vector(I n, const T& x) { return std::vector(n, x); } template auto make_vector(I i, J j, K k, Ts&&... xs) { return std::vector(i, make_vector(j, k, xs...)); } struct Initialization { Initialization() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); } } initialization; template void println(std::format_string fmt, Args&&... args) { std::println(std::cout, fmt, std::forward(args)...); } void println() { std::println(std::cout); } template void println(Arg&& arg) { std::println(std::cout, "{}", std::forward(arg)); } template void eprintln(std::format_string fmt, Args&&... args) { std::println(std::cerr, fmt, std::forward(args)...); } void eprintln() { std::println(std::cerr); } template void eprintln(Arg&& arg) { std::println(std::cerr, "{}", std::forward(arg)); } constexpr const std::pair DIRS[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; constexpr const std::pair DIRS8[] = { {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}}; template using infs = std::numeric_limits; template using pq_rev = std::priority_queue, std::greater>; namespace pbds = __gnu_pbds; template using tree = pbds::tree, pbds::rb_tree_tag, pbds::tree_order_statistics_node_update>; template class range { T left, right, step; struct iterator { T val, step; T operator*() const { return val; } iterator& operator++() { val += step; return *this; } iterator& operator--() { val -= step; return *this; } constexpr bool operator!=(T rhs) const { return val != rhs; } }; public: constexpr range(T r) : range(0, r) {} constexpr range(T l, T r) : range(l, r, 1) {} constexpr range(T l, T r, T st) : left(l), right(r), step(st) { if (right < left) { right = left; } else if (T m = (right - left) % step; m != 0) { right -= m; right += step; } } constexpr iterator begin() const { return iterator(left, step); } constexpr T end() const { return right; } constexpr inline size_t size() const { return (right - left) / step; } constexpr inline bool has(T x) const { return left <= x and x < right and (x - left) % step == 0; } }; template struct factorials { static size_t n; static std::vector fact, inv_fact; static inline void extend(size_t m) { if (m <= n) return; fact.resize(m + 1); inv_fact.resize(m + 1); for (size_t i = n + 1; i <= m; i++) fact[i] = fact[i - 1] * i; inv_fact[m] = fact[m].inv(); for (size_t i = m; i > n + 1; i--) inv_fact[i - 1] = inv_fact[i] * i; n = m; } static T inv(int k) { extend(k); return inv_fact[k]; } static T get(int k) { extend(k); return fact[k]; } static T perm(int n, int k) { if (n < k) return 0; if (k < 0) return 0; extend(n); return fact[n] * inv_fact[n - k]; } static T choose(int n, int k) { if (n < k) return 0; if (k < 0) return 0; extend(n); return fact[n] * inv_fact[n - k] * inv_fact[k]; } static T catalan(int n) { return get(2 * n) * inv(n + 1) * inv(n); } }; template size_t factorials::n = 0; template std::vector factorials::fact = {1}; template std::vector factorials::inv_fact = {1}; #if __has_include() || USE_ACLIBRARY using mint = atcoder::modint998244353; // using mint = atcoder::modint1000000007; using fs = factorials; #endif int main() { ll T, x0, y0, xT, yT; std::cin >> T >> x0 >> y0 >> xT >> yT; ll ok = 0, ng = T; auto dist = [](ll x1, ll y1, ll x2, ll y2) -> ll { return std::abs(x1 - x2) + std::abs(y1 - y2); }; while (ng - ok > 1) { ll mid = (ok + ng) / 2; println("? {}", mid); std::cout.flush(); ll x, y; std::cin >> x >> y; if (dist(x0, y0, x, y) <= dist(xT, yT, x, y)) { ok = mid; } else { ng = mid; } } println("! {}", ok); }