unittest
{
	assert( [ "4 4", "2 4", "1 1", "2 3", "2 4" ].solve == "1\n3\n6\n-1" );
}



import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto h = 0L;
	auto w = 0L;
	input.front.formattedRead!"%s %s"( h, w );
	auto abs = new long[ 2 ][ h ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[ 0 ] -= 1;
	}
	
	auto anss = new long[ h ];
	auto rbt = redBlackTree( iota( 0L, w ) );
	auto st = SegmentTree!( long, min, long.max )( new long[ w + 1 ] );
	foreach( y, ref ans, ab; lockstep( anss, abs ) )
	{
		auto xs = rbt.upperBound( ab[ 0 ] - 1 );
		auto p = false;
		while( !xs.empty && xs.front < ab[ 1 ] )
		{
			auto x = xs.front;
			xs.popFront;
			rbt.removeKey( x );
			st.set( ab[ 1 ], min( st.get( ab[ 1 ] ), st.get( x ) + ab[ 1 ] - x ) );
			st.set( x, long.max );
			p = true;
		}
		if( p && ab[ 1 ] < w ) rbt.insert( ab[ 1 ] );
		auto m = st.query( 0, w );
		if( m == long.max ) ans = -1;
		else                ans = y + 1 + m;
	}
	return anss.to!( string[] ).join( "\n" );
}

// セグメント木
struct SegmentTree( T, alias op = ( ( a, b ) => a + b ), T I = T.init )
{
	T[] ts;
	
	this( long n )
	{
/*
		// opについて交換法則 ( A op B ) op C == A op ( B op C ) が成り立たないときはnを2^^xに切り上げする
		auto m = 1L;
		while( m < n ){ m <<= 1; }
		ts = new T[ m << 1 ];
*/
		ts = new T[ n << 1 ];
		static if( I != T.init ) ts[] = I;
	}
	
	this( T[] qs )
	{
/*
		// opについて交換法則 ( A op B ) op C == A op ( B op C ) が成り立たないときはnを2^^xに切り上げする
		auto n = 1L;
		while( n < qs.length ){ n <<= 1; }
		ts = new T[ n << 1 ];
*/
		ts = new T[ qs.length << 1 ];
		ts[ $ >> 1 .. ( $ >> 1 ) + qs.length ] = qs;
		foreach_reverse( i; 1L .. ts.length.signed >> 1 )
		{
			ts[ i ] = op( ts[ i << 1 ], ts[ i << 1 | 1 ] );
		}
	}
	
	void set( long i, T v )
	{
		i += ts.length.signed >> 1;
		ts[ i ] = v;
		for( i >>= 1; 0 < i; i >>= 1 )
		{
			ts[ i ] = op( ts[ i << 1 ], ts[ i << 1 | 1 ] );
		}
	}
	
	auto get( long i )
	{
		i += ts.length.signed >> 1;
		return ts[ i ];
	}
	
	auto query( long l, long r )
	{
		l += ts.length.signed >> 1;
		r += ts.length.signed >> 1;
		auto x = I;
		auto y = I;
		for( ; l < r; l >>= 1, r >>= 1 )
		{
			if( l & 1 )
			{
				x = op( x, ts[ l ] );
				l++;
			}
			if( r & 1 )
			{
				r--;
				y = op( ts[ r ], y );
			}
		}
		return op( x, y );
	}
	
	auto length()
	{
		return ts.length >> 1;
	}
	
	auto toString()
	{
		return format( "ST(%s)", ts[ $ >> 1 .. $ ] );
	}
}
