Lis on Circle

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

There are nn people at the round gaming table. Each of them has a set of cards. Every card contains some number xx. Players make turns consecutively, one after another, starting from the player number 1. A player in his turn can either skip his turn (to pass), or put (and leave on the table) a card with a number that is strictly greater than the previously played last number. No more than kk players in a row can pass the turn. All players know the numbers written on the other players cards and always play optimally. Help gamblers to assemble an increasing sequence of maximum length.

입력

The first line contains two numbers nn and kk --- the number of players and the maximum possible amount of turn skipping in a row.

The next nn lines contain the description of the cards players have in their hands. The first number in the m_im\_i is the number of cards the current player has in his hand. The following space separated m_im\_i numbers represent the written on the cards numbers xx.

출력

In the first line print the single number --- the length of the maximum sequence. In the next lines print two space separated numbers: the player index number and the number written on the card he played. If several solutions exist, output any of them.

제한

  • 0m_i1050 \le \sum m\_i \le 10^5
  • 1n1051 \le n \le 10^5
  • 0k<n0 \le k < n
  • 0x1090 \le x \le 10^9