/*********
　　Supercon 2009 1級認定問題 および 予選問題 雛形プログラム
　　2009/06/01
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXSQUARES (50000)

int a[MAXSQUARES];
int b[MAXSQUARES];
int n;
int d;
int result = -1;
void initialize();
void finalize();

/*********
　　解答プログラムの作成方法
　　以下の main() を書き換え，プログラムを作成して下さい．
　　結果は result に代入して下さい．
　　注１）main() 内の変更・削除不可の行は変えないで下さい．
　　注２）参考のため，以下に全データを出力するプログラムを示していま
　　　　　すが，これは削除，修正してかまいません．
　　注３）関数定義等は適宜加えてもよいです．ただし，１つのプログラム
　　      ファイルとして提出して下さい．
*/

/*********
　　説明：
　　initialize(), finalize() 呼び出しの間のみ以下が利用可能となる
　　a[i]: i番目の正方形の左下頂点のx座標
　　b[i]: i番目の正方形の左下頂点のy座標
　　n: 正方形の総数
　　d: 正方形の辺の長さ
　　result: 結果保存先（int 型）
*/

int main(int argc, char** argv){  /* 変更・修正不可 */
	int i;
	initialize();        /* 変更・修正不可 */

	for(i = 0; i < n; i++){
		printf("%d %d\n", a[i], b[i]);
	}

	finalize();          /* 変更・修正不可 */
	return EXIT_SUCCESS; /* 変更・修正不可 */
}

/*********
　　以下はすべて変更・修正不可
*/
#define MAXBUF (256)
void initialize()
{
	char buffer[MAXBUF];
	int i;
	fgets(buffer, MAXBUF, stdin);
	if(strchr(buffer, '\n') == NULL){
	  fprintf(stderr, "Data reading error: please report to the Supercon09 committee this message\n");
		exit(EXIT_FAILURE);
	} else {
		sscanf(buffer, "%d %d\n", &n, &d);
	}
	for(i = 0; i < n; i++) {
    fgets(buffer, MAXBUF, stdin);
  	if(strchr(buffer, '\n') == NULL){
	    fprintf(stderr, "Data reading error: please report to the Supercon09 committee this message\n");
		  exit(EXIT_FAILURE);
	  } else {
		  sscanf(buffer, "%d %d\n", &a[i], &b[i]);
	  }
	}
	return;
}

void finalize()
{
	printf("Final Answer: %d\n", result);
	return;
}
