PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CC0000027. Danh sách tin nhắn gần nhất (Messenger Simulator)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Danh sách tin nhắn gần nhất (Messenger Simulator)

Messenger Simulator

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn friends initially ordered 1,2,…,n1,2,\ldots,n in a recent-chat list, with the topmost friend at position 11. Whenever friend xx sends a message, that friend moves to the top and the friends previously above them shift down by one position. For every friend, determine the smallest and largest positions ever occupied, including the initial state.

Input

The first line contains n,mn,m. The next line contains mm sender IDs a1,…,ama_1,\ldots,a_m.

Output

Print nn lines. Line ii contains the minimum and maximum one-based positions ever held by friend ii.

Subtasks

  • Subtask 1 (20 points): 1≤n,m≤201\le n,m\le 20; 1≤ai≤n1\le a_i\le n.
  • Subtask 2 (30 points): 1≤n,m≤9001\le n,m\le 900; 1≤ai≤n1\le a_i\le n.
  • Subtask 3 (50 points): 1≤n,m≤3000001\le n,m\le 300000; 1≤ai≤n1\le a_i\le n.

Examples

Input

5 4
3 5 1 4

Output

1 3
2 5
1 4
1 5
1 5

Explanation

The list changes by moving each sender to the front. Friend 2 visits positions 2,3,4,4,5, so their minimum and maximum are 2 and 5.