#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int H, W;
int A[200005], B[200005];

int C[200005];
set<int > S;

int ans[200005];

multiset<int> M;

int p = 0;
int E[200005];

void ADD(int k) {
	E[k]++;
}
void DEL(int k) {
	E[k]--;
	
	while (E[p] == 0) { p++; }
}

int main(void) {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		cin >> A[i] >> B[i];
	}

	for (int i = 1; i <= W; i++) { S.insert(i); M.insert(0); /*ADD(0);*/ }
	
	/*if (A[1] == 1 && B[1] == W) { for (int i = 1; i <= H; i++) { cout << -1 << endl; } return 0; }

	if (A[1]==1) {}
	else if (A[1] == 2) { S.insert(1); M.insert(0); }
	else { S.insert(1); M.insert(0);  S.insert(A[1] - 1); M.insert(0); }

	if (B[1] < W) {
		S.insert(B[1] + 1); M.insert(0);
	}
	ans[1] = 1;*/
	
	for (int i = 1; i <= H; i++) {
		
		//cout << "i= " << i << endl;

		//-----------------
		auto it = S.upper_bound(B[i] + 1);
		//auto  it = upper_bound(S.begin(), S.end(), B[i] + 1);
		if (it != S.begin()) { --it; }
		if (it!=S.end() && *it <= B[i] + 1 && ( B[i]+1<=W)) {
			C[B[i] + 1] = C[*it] + B[i] + 1 - (*it); 

			if (S.find(B[i] + 1) != S.end()) {
				auto itr = M.find(C[B[i] + 1]);  M.erase(itr);
			}
			S.insert(B[i] + 1);  M.insert(C[B[i] + 1]); 
		}

		//cout << "S: "; for (auto y : S) { cout << " " << y; }cout << endl;
		//cout << "M: "; for (auto y : M) { cout << " " << y; }cout << endl;

		//--------------------------------------------------------
		
		it = S.upper_bound(A[i] - 1);
		//it = upper_bound(S.begin(), S.end(), A[i] - 1);
		if (it != S.begin()) { --it; }
		if (it!=S.end() && *it <= A[i] - 1  &&  A[i]-1>=1) {
			C[A[i] - 1] = C[*it] + A[i] - 1 - (*it);
			if (S.find(A[i] - 1) != S.end()) { 
				auto itr = M.find(C[A[i]-1]);  M.erase(itr);                              
			}
			S.insert(A[i] - 1); M.insert(C[A[i] - 1]);
		}

		//cout << "S: "; for (auto y : S) { cout << " " << y; }cout << endl;
		//cout << "M: "; for (auto y : M) { cout << " " << y; }cout << endl;
		
		//--------------------------------

		it = S.lower_bound(A[i]);
		//it = lower_bound(S.begin(), S.end(), A[i]);
		while (it!=S.end() && *it <= B[i]) {
			auto itr = M.find(C[*it]); //cout << *itr << " 消去" << endl;
			M.erase(itr); 
			//DEL(C[*it]);
			 S.erase(it++);
		}

		//cout << "S: "; for (auto y : S) { cout << " " << y; }cout << endl;
		//cout << "M: "; for (auto y : M) { cout << " " << y; }cout << endl;

		//cout << "i= " << i << endl;
		//cout << "E:"; for (int i = 0; i <= 10; i++) { cout << " " << E[i]; } cout << " p= " << p << endl;

		if (S.size() == 0) { ans[i] = -1; }
		else { ans[i] = i + *M.begin()/*p*/; }

	}

	
	for (int i = 1; i <= H; i++) {
		printf("%d\n", ans[i]);
		//cout << ans[i] << endl;
	}

	return 0;
}
#include <iostream>
#ifdef MBP
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define REP(i, n) for (long long int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_R(i, n) for (long long int i = (n - 1); i >= 0; --i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((long long int)(x).size())
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF INT_MAX
#define INFLL LLONG_MAX
#define PB push_back
#define MOD 1000000007LL
#define LSB(x) __builtin_ctzll(x)
#define MSB(x) 64LL - __builtin_clzll(x) - 1LL
#define MSBINT(x) 32LL - __builtin_clz(x)
#define BITCNT(x) __builtin_popcountll(x)

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using vec = vector<ll>;
using mat = vector<vector<ll>>;
using pa = pair<ll, ll>;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template <class T>
using PQ = priority_queue<T>;
template <class T>
using PQG = priority_queue<T, vector<T>, greater<T>>;

const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
const ll dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);

ll qp(ll a, ll b);
ll qp(ll a, ll b, ll mo);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void init_fact();

ll combination(ll, ll);

#define FACSIZE 200002LL

ll invfac[FACSIZE];
ll fac[FACSIZE];

pa pos(ll x)
{
  pa p;
  p.first = (x / 49) * 2 + 1;
  p.second = (x % 49) * 2 + 1;

  return p;
}

int main(void)
{
  ll a, b;
  cin >> a >> b;

  mat field(100, vec(100, 0));
  REP(i, 50)
  REP(j, 100)
  field[i][j] = 1;

  REP(i, a - 1)
  {
    auto p = pos(i);
    field[p.first][p.second] = 0;
  }
  REP(i, b - 1)
  {
    auto p = pos(i);
    field[p.first + 50][p.second] = 1;
  }
  cout << 100 << " " << 100 << endl;
  REP(i, 100)
  {
    REP(j, 100)
    {
      auto x = field[i][j];
      if (x == 1)
      {
        cout << '#';
      }
      else
      {
        cout << '.';
      }
    }
    cout << endl;
  }

  return 0;
}

template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % MOD;
    a = 1LL * mod_mul(a, a) % MOD;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % MOD;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % MOD;
    return t * t % MOD;
  }
  else
  {
    ll t = mod_pow(x, r / 2) % MOD;
    ll k = t * t % MOD;
    return k * x % MOD;
  }
}
ll mod_add(ll a, ll b)
{
  return (a + b) % MOD;
}

ll mod_mul(ll a, ll b)
{
  return (a * b) % MOD;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, MOD - 2));
}

void make_fact(ll n)
{
  fac[0] = 1;
  REP(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], MOD - 2);
  REP_R(i, n)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

void init_fact()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE - 1);
}

ll combination(ll n, ll c)
{

  return mod_mul(fac[n], mod_mul(invfac[c], invfac[n - c]));
}
///////////////fact
/*
  init_fact();
  cout << fac[5] << endl;
  cout << invfac[5] << endl;
  cout << combination(8, 4) << endl;
  cout << combination(31, 8) << endl;
  //*/
///////////////////
