using System; using System.Collections; //using System.Linq; using System.Collections.Generic; using LidelieLibrary; using static LidelieLibrary.Input; using static LidelieLibrary.Functions; using static LidelieLibrary.MathExt; using System.IO; using System.Text; using System.Numerics; class Solver{ static void Main(string[] args){ var(x,y)=Assign(); Out(x*y+" "+x*y); var q = new Queue(); for(int i = x+1;i<=x*y;i++)q.Enqueue(i); for(int i = 1;i<=x;i++){ Out(i+" "+(i+1>x?1:i+1)); } for(int i = 1;i<=x;i++){//makearm int root = i; for(int j = 0;j : Set where T : IComparable { public override void Insert(T v) { if (_root == null) _root = new SB_BinarySearchTree.Node(v); else _root = SB_BinarySearchTree.Insert(_root, v); } } public class SB_BinarySearchTree where T : IComparable { public class Node { public T Value; public Node LChild; public Node RChild; public int Count; //size of the sub tree public Node(T v) { Value = v; Count = 1; } } static Random _rnd = new Random(); public static int Count(Node t) { return t == null ? 0 : t.Count; } static Node Update(Node t) { t.Count = Count(t.LChild) + Count(t.RChild) + 1; return t; } public static Node Merge(Node l, Node r) { if (l == null || r == null) return l == null ? r : l; if ((double)Count(l) / (double)(Count(l) + Count(r)) > _rnd.NextDouble()) { l.RChild = Merge(l.RChild, r); return Update(l); } else { r.LChild = Merge(l, r.LChild); return Update(r); } } /// /// split as [0, k), [k, n) /// public static Tuple Split(Node t, int k) { if (t == null) return new Tuple(null, null); if (k <= Count(t.LChild)) { var s = Split(t.LChild, k); t.LChild = s.Item2; return new Tuple(s.Item1, Update(t)); } else { var s = Split(t.RChild, k - Count(t.LChild) - 1); t.RChild = s.Item1; return new Tuple(Update(t), s.Item2); } } public static Node Remove(Node t, T v) { if (Find(t, v) == null) return t; return RemoveAt(t, LowerBound(t, v)); } public static Node RemoveAt(Node t, int k) { var s = Split(t, k); var s2 = Split(s.Item2, 1); return Merge(s.Item1, s2.Item2); } public static bool Contains(Node t, T v) { return Find(t, v) != null; } public static Node Find(Node t, T v) { while (t != null) { var cmp = t.Value.CompareTo(v); if (cmp > 0) t = t.LChild; else if (cmp < 0) t = t.RChild; else break; } return t; } public static Node FindByIndex(Node t, int idx) { if (t == null) return null; var currentIdx = Count(t) - Count(t.RChild) - 1; while (t != null) { if (currentIdx == idx) return t; if (currentIdx > idx) { t = t.LChild; currentIdx -= (Count(t == null ? null : t.RChild) + 1); } else { t = t.RChild; currentIdx += (Count(t == null ? null : t.LChild) + 1); } } return null; } public static int UpperBound(Node t, T v) { var torg = t; if (t == null) return -1; var ret = Int32.MaxValue; var idx = Count(t) - Count(t.RChild) - 1; while (t != null) { var cmp = t.Value.CompareTo(v); if (cmp > 0) { ret = Math.Min(ret, idx); t = t.LChild; idx -= (Count(t == null ? null : t.RChild) + 1); } else if (cmp <= 0) { t = t.RChild; idx += (Count(t == null ? null : t.LChild) + 1); } } return ret == Int32.MaxValue ? Count(torg) : ret; } public static int LowerBound(Node t, T v) { var torg = t; if (t == null) return -1; var idx = Count(t) - Count(t.RChild) - 1; var ret = Int32.MaxValue; while (t != null) { var cmp = t.Value.CompareTo(v); if (cmp >= 0) { if (cmp == 0) ret = Math.Min(ret, idx); t = t.LChild; if (t == null) ret = Math.Min(ret, idx); idx -= t == null ? 0 : (Count(t.RChild) + 1); } else if (cmp < 0) { t = t.RChild; idx += (Count(t == null ? null : t.LChild) + 1); if (t == null) return idx; } } return ret == Int32.MaxValue ? Count(torg) : ret; } public static Node Insert(Node t, T v) { var ub = LowerBound(t, v); return InsertByIdx(t, ub, v); } static Node InsertByIdx(Node t, int k, T v) { var s = Split(t, k); return Merge(Merge(s.Item1, new Node(v)), s.Item2); } public static IEnumerable Enumerate(Node t) { var ret = new List(); Enumerate(t, ret); return ret; } static void Enumerate(Node t, List ret) { if (t == null) return; Enumerate(t.LChild, ret); ret.Add(t.Value); Enumerate(t.RChild, ret); } } public class Set where T : IComparable { protected SB_BinarySearchTree.Node _root; public T this[int idx]{ get { return ElementAt(idx); } } public int Count() { return SB_BinarySearchTree.Count(_root); } public virtual void Insert(T v) { if (_root == null) _root = new SB_BinarySearchTree.Node(v); else { if (SB_BinarySearchTree.Find(_root, v) != null) return; _root = SB_BinarySearchTree.Insert(_root, v); } } public void Clear() { _root = null; } public void Remove(T v) { _root = SB_BinarySearchTree.Remove(_root, v); } public bool Contains(T v) { return SB_BinarySearchTree.Contains(_root, v); } public T ElementAt(int k) { var node = SB_BinarySearchTree.FindByIndex(_root, k); if (node == null) throw new IndexOutOfRangeException(); return node.Value; } public int Count(T v) { return SB_BinarySearchTree.UpperBound(_root, v) - SB_BinarySearchTree.LowerBound(_root, v); } public int LowerBound(T v) { return SB_BinarySearchTree.LowerBound(_root, v); } public int UpperBound(T v) { return SB_BinarySearchTree.UpperBound(_root, v); } public Tuple EqualRange(T v) { if (!Contains(v)) return new Tuple(-1, -1); return new Tuple(SB_BinarySearchTree.LowerBound(_root, v), SB_BinarySearchTree.UpperBound(_root, v) - 1); } public List ToList() { return new List(SB_BinarySearchTree.Enumerate(_root)); } } class Cmp : IComparer { readonly long[] a; readonly long[] b; public Cmp(long[] aa,long[] bb){ a = aa; b = bb; } public int Compare(object x,object y){ int i = (int)x; int j = (int)y; int r; if((a[i]*(a[j]+b[j])){ public readonly int Length; public Annulus(T[] arr){ Length=arr.Length; } int RevolveCW(int from,int count){return (from+count)%Length;} int RevolveCCW(int from,int count){return (from-count)%Length;} } class SegmentTree{ public readonly int Size; public long[] SegTree; Func Updator; public SegmentTree(long[] arr,long init,Func updator){ int p = PowerOfTwo(arr.Length); Size = (int)Math.Pow(2,p); SegTree = new long[2*Size]; for(int i = 0;i=1;i--){ SegTree[i] = Updator(SegTree[2*i],SegTree[2*i+1]); } } public void Access(int index,long num){ SegTree[Size+index] = num; Update(Size+index); } public int Index(int i){return Size+i;} void Update(int p){ int i=p/2; SegTree[i] = Updator(SegTree[2*i],SegTree[2*i+1]); if(i==1)return; Update(i); } public List Segment(int l,int r){ l = Size+l; r = Size+r; int s = l; var res = new List(); while(s=r)break; ind = ind/2; range=range*2; } s = s+range; res.Add(SegTree[ind]); } return res; } } class Dimension{ public readonly int H; public readonly int W; public Dimension(int h,int w){ H=h; W=w; } public int Lower(int i,int j){return W*i+j;} public (int,int) Upper(int i){return(i/W,i%W);} public bool IsRange(int i,int j){ if(0<=i&&i(Dictionary dic,TKey key,TValue value) where TValue : INumber{ if(dic.ContainsKey(key))dic[key]+=value; else dic.Add(key,value); } public static void Add(Dictionary> dic,TKey key,TValue value) {//where TValue : INumber{ if(dic.ContainsKey(key))dic[key].Add(value); else{ dic.Add(key,new List()); dic[key].Add(value); } } public static char[] Reverse(char[] c){ for(int i = 0;i=0;i--){ if(((a>>i)&1)==1)return i+1; } return 0; } public static int PowerOfTwo(int a){ for(int i = 30;i>=0;i--){ if(((a>>i)&1)==1)return i+1; } return 0; } public static double Distance(int ax,int ay,int bx,int by){ return Math.Sqrt(Math.Pow(ax-bx,2)+Math.Pow(ay-by,2)); } public static double Distance(double ax,double ay,double bx,double by){ return Math.Sqrt(Math.Pow(ax-bx,2)+Math.Pow(ay-by,2)); } public static double Distance((int x,int y)a,(int x,int y)b){ return Math.Sqrt(Math.Pow(a.x-b.x,2)+Math.Pow(a.y-b.y,2)); } public static double Distance(int ax,int ay,int az,int bx,int by,int bz){ return Math.Pow(Math.Pow(ax-bx,2)+Math.Pow(ay-by,2)+Math.Pow(az-bz,2),1/3); } public static int LowerBound(int[] array,int targ){ var ok = array.Length; var ng = -1; var m = 0; while(ok-ng>1){ m = ng + (ok-ng)/2; if(array[m]>=targ)ok = m; else ng = m; } return ok; } public static int LowerBound(long[] array,long targ){ var ok = array.Length; var ng = -1; var m = 0; while(ok-ng>1){ m = ng + (ok-ng)/2; if(array[m]>=targ)ok = m; else ng = m; } return ok; } public static int LowerBound(List list,long targ){ var ok = list.Count; var ng = -1; var m = 0; while(ok-ng>1){ m = ng + (ok-ng)/2; if(list[m]>=targ)ok = m; else ng = m; } return ok; } } class MathExt{ public static long Powl(long a,long b){ long res = 1; for(int i = 0;i /// Enumerate primes that n or less. /// BEWARE OF MLE /// /// /// public static List Primes(long n){ if(n>12000000){ Console.WriteLine("Are you going to break your PC?"); Console.WriteLine("(Input:"+n+")"); return new List(); } var res = new List(); var set = new HashSet(); for(int i = 2;i<=n;i++) set.Add(i); long k = 2; while(k<=n){ for(long i = 2*k;i<=n;i+=k){ set.Remove(i); } k++; while(!set.Contains(k)&&k<=n){ k++; } } foreach(long l in set)res.Add(l); return res; } public static Dictionary PrimeFactorize(long n,List primes){//damekamo var res = new Dictionary(); long val = n; foreach(long p in primes){ if(p>n/2)break; while(val%p==0){ val/=p; Add(res,p,1); } } if(val!=1&&!res.ContainsKey(val))Add(res,val,1); return res; } public static long Factorial(long n){ long res = 1; for(long i = 2;i<=n;i++)res*=i; return res; } public static int P(int n,int r){ int res = 1; for(int i = n;i>n-r;i--)res *= i; return res; } public static int C(int n,int r){ int res = 1; for(int i = n;i>n-r;i--)res *= i; for(int i = r;i>1;i--)res /= i; return res; } public static long C(long n,long r){ long res = 1; for(long i = n;i>n-r;i--)res *= i; for(long i = r;i>1;i--)res /= i; return res; } public static long gcd(long a,long b){ if(a(T[] array,int r){ // int n = array.Length; // int cnt = P(n,r); // T[][] res = new T[cnt][]; // for(int i = 0;i(); // var chosen = new HashSet(); // for(int i = 0;i /// Enumerate Combinations of choosing r items from an array. /// /// An jagged array. public static int[][] Combination(int[] array,int r){ int n = array.Length; int[][] res = new int[C(n,r)][]; for(int i = 0;i(); for(int i = 0;i<=n-r;i++){ DFS(i,0); } void DFS(int i,int k) { l.Add(array[i]); if(k==r-1){ res[created]=l.ToArray(); created++; } else for(int j = i+1;j<=n-r+k+1;j++){ DFS(j,k+1); } l.RemoveAt(l.Count-1); } return res; } public static long[][] Combination(long[] array,long r){ int n = array.Length; long[][] res = new long[C(n,r)][]; for(int i = 0;i(); for(int i = 0;i<=n-r;i++){ DFS(i,0); } void DFS(int i,int k) { l.Add(array[i]); if(k==r-1){ res[created]=l.ToArray(); created++; } else for(int j = i+1;j<=n-r+k+1;j++){ DFS(j,k+1); } l.RemoveAt(l.Count-1); } return res; } public static T[][] Combination(T[] array,long r){ int n = array.Length; T[][] res = new T[C(n,r)][]; for(int i = 0;i(); for(int i = 0;i<=n-r;i++){ DFS(i,0); } void DFS(int i,int k) { l.Add(array[i]); if(k==r-1){ res[created]=l.ToArray(); created++; } else for(int j = i+1;j<=n-r+k+1;j++){ DFS(j,k+1); } l.RemoveAt(l.Count-1); } return (T[][])res; } } class Input{ public static void Out((int,int) arg){Console.WriteLine(arg.Item1+" "+arg.Item2);} public static void Out((long,long) arg){Console.WriteLine(arg.Item1+' '+arg.Item2);} public static void Out(List arg){Console.WriteLine(string.Join(' ',arg));} public static void Out(List arg){Console.WriteLine(string.Join(' ',arg));} public static void Out(List arg){Console.WriteLine(string.Join(' ',arg));} public static void Out(List arg){Console.WriteLine(string.Join(' ',arg));} public static void Out(int[] arg){Console.WriteLine(string.Join(' ',arg));} public static void Out(long[] arg){Console.WriteLine(string.Join(' ',arg));} public static void Out(string[] arg){Console.WriteLine(string.Join(' ',arg));} public static void Out(char[] arg){Console.WriteLine(string.Join(' ',arg));} public static void Out(object arg){Console.WriteLine(arg);} public static void Yes(){Console.WriteLine("Yes");} public static void No(){Console.WriteLine("No");} static Queue input = new Queue(); public static T Assign(){ object re = null; if(typeof(T) == typeof(string[]))re = Console.ReadLine().Split(' '); //if(typeof(T) == typeof(char[]))re = Array.ConvertAll(Console.ReadLine().Split(' '),char.Parse); if(typeof(T) == typeof(int[]))re = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse); if(typeof(T) == typeof(long[]))re = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse); if(typeof(T) == typeof(float[]))re = Array.ConvertAll(Console.ReadLine().Split(' '),float.Parse); if(typeof(T) == typeof(double[]))re = Array.ConvertAll(Console.ReadLine().Split(' '),double.Parse); if(re!=null){ return (T)re; } if(input.Count == 0){ foreach(string item in Console.ReadLine().Split(' ')){ input.Enqueue(item); } } if(typeof(T) == typeof(string))re = input.Dequeue(); if(typeof(T) == typeof(char))re = char.Parse(input.Dequeue()); if(typeof(T) == typeof(char[]))re = input.Dequeue().ToCharArray(); if(typeof(T) == typeof(int))re = int.Parse(input.Dequeue()); if(typeof(T) == typeof(long))re = long.Parse(input.Dequeue()); if(typeof(T) == typeof(ulong))re = ulong.Parse(input.Dequeue()); if(typeof(T) == typeof(float))re = float.Parse(input.Dequeue()); if(typeof(T) == typeof(double))re = double.Parse(input.Dequeue()); return (T)re; } public static (T1,T2) Assign(){ while(input.Count < 2){ foreach(string item in Console.ReadLine().Split(' ')){ input.Enqueue(item); } } (object a,object b) re = (null,null); if(typeof(T1) == typeof(string))re.a = input.Dequeue(); if(typeof(T1) == typeof(char))re.a = char.Parse(input.Dequeue()); if(typeof(T1) == typeof(char[]))re.a = input.Dequeue().ToCharArray(); if(typeof(T1) == typeof(int))re.a = int.Parse(input.Dequeue()); if(typeof(T1) == typeof(long))re.a = long.Parse(input.Dequeue()); if(typeof(T1) == typeof(ulong))re.a = ulong.Parse(input.Dequeue()); if(typeof(T1) == typeof(float))re.a = float.Parse(input.Dequeue()); if(typeof(T1) == typeof(double))re.a = double.Parse(input.Dequeue()); if(typeof(T2) == typeof(string))re.b = input.Dequeue(); if(typeof(T2) == typeof(char))re.b = char.Parse(input.Dequeue()); if(typeof(T2) == typeof(char[]))re.b = input.Dequeue().ToCharArray(); if(typeof(T2) == typeof(int))re.b = int.Parse(input.Dequeue()); if(typeof(T2) == typeof(long))re.b = long.Parse(input.Dequeue()); if(typeof(T2) == typeof(ulong))re.b = ulong.Parse(input.Dequeue()); if(typeof(T2) == typeof(float))re.b = float.Parse(input.Dequeue()); if(typeof(T2) == typeof(double))re.b = double.Parse(input.Dequeue()); return ((T1,T2))re; } public static (T1,T2,T3) Assign(){ while(input.Count < 3){ foreach(string item in Console.ReadLine().Split(' ')){ input.Enqueue(item); } } (object a,object b,object c) re = (null,null,null); if(typeof(T1) == typeof(string))re.a = input.Dequeue(); if(typeof(T1) == typeof(char))re.a = char.Parse(input.Dequeue()); if(typeof(T1) == typeof(char[]))re.a = input.Dequeue().ToCharArray(); if(typeof(T1) == typeof(int))re.a = int.Parse(input.Dequeue()); if(typeof(T1) == typeof(long))re.a = long.Parse(input.Dequeue()); if(typeof(T1) == typeof(ulong))re.a = ulong.Parse(input.Dequeue()); if(typeof(T1) == typeof(float))re.a = float.Parse(input.Dequeue()); if(typeof(T1) == typeof(double))re.a = double.Parse(input.Dequeue()); if(typeof(T2) == typeof(string))re.b = input.Dequeue(); if(typeof(T2) == typeof(char))re.b = char.Parse(input.Dequeue()); if(typeof(T2) == typeof(char[]))re.b = input.Dequeue().ToCharArray(); if(typeof(T2) == typeof(int))re.b = int.Parse(input.Dequeue()); if(typeof(T2) == typeof(long))re.b = long.Parse(input.Dequeue()); if(typeof(T2) == typeof(ulong))re.b = ulong.Parse(input.Dequeue()); if(typeof(T2) == typeof(float))re.b = float.Parse(input.Dequeue()); if(typeof(T2) == typeof(double))re.b = double.Parse(input.Dequeue()); if(typeof(T3) == typeof(string))re.c = input.Dequeue(); if(typeof(T3) == typeof(char))re.c = char.Parse(input.Dequeue()); if(typeof(T3) == typeof(char[]))re.c = input.Dequeue().ToCharArray(); if(typeof(T3) == typeof(int))re.c = int.Parse(input.Dequeue()); if(typeof(T3) == typeof(long))re.c = long.Parse(input.Dequeue()); if(typeof(T3) == typeof(ulong))re.c = ulong.Parse(input.Dequeue()); if(typeof(T3) == typeof(float))re.c = float.Parse(input.Dequeue()); if(typeof(T3) == typeof(double))re.c = double.Parse(input.Dequeue()); return ((T1,T2,T3))re; } public static (T1,T2,T3,T4) Assign(){ while(input.Count < 4){ foreach(string item in Console.ReadLine().Split(' ')){ input.Enqueue(item); } } (object a,object b,object c,object d) re = (null,null,null,null); if(typeof(T1) == typeof(string))re.a = input.Dequeue(); if(typeof(T1) == typeof(char))re.a = char.Parse(input.Dequeue()); if(typeof(T1) == typeof(char[]))re.a = input.Dequeue().ToCharArray(); if(typeof(T1) == typeof(int))re.a = int.Parse(input.Dequeue()); if(typeof(T1) == typeof(long))re.a = long.Parse(input.Dequeue()); if(typeof(T1) == typeof(ulong))re.a = ulong.Parse(input.Dequeue()); if(typeof(T1) == typeof(float))re.a = float.Parse(input.Dequeue()); if(typeof(T1) == typeof(double))re.a = double.Parse(input.Dequeue()); if(typeof(T2) == typeof(string))re.b = input.Dequeue(); if(typeof(T2) == typeof(char))re.b = char.Parse(input.Dequeue()); if(typeof(T2) == typeof(char[]))re.b = input.Dequeue().ToCharArray(); if(typeof(T2) == typeof(int))re.b = int.Parse(input.Dequeue()); if(typeof(T2) == typeof(long))re.b = long.Parse(input.Dequeue()); if(typeof(T2) == typeof(ulong))re.b = ulong.Parse(input.Dequeue()); if(typeof(T2) == typeof(float))re.b = float.Parse(input.Dequeue()); if(typeof(T2) == typeof(double))re.b = double.Parse(input.Dequeue()); if(typeof(T3) == typeof(string))re.c = input.Dequeue(); if(typeof(T3) == typeof(char))re.c = char.Parse(input.Dequeue()); if(typeof(T3) == typeof(char[]))re.c = input.Dequeue().ToCharArray(); if(typeof(T3) == typeof(int))re.c = int.Parse(input.Dequeue()); if(typeof(T3) == typeof(long))re.c = long.Parse(input.Dequeue()); if(typeof(T3) == typeof(ulong))re.c = ulong.Parse(input.Dequeue()); if(typeof(T3) == typeof(float))re.c = float.Parse(input.Dequeue()); if(typeof(T3) == typeof(double))re.c = double.Parse(input.Dequeue()); if(typeof(T4) == typeof(string))re.d = input.Dequeue(); if(typeof(T4) == typeof(char))re.d = char.Parse(input.Dequeue()); if(typeof(T4) == typeof(char[]))re.d = input.Dequeue().ToCharArray(); if(typeof(T4) == typeof(int))re.d = int.Parse(input.Dequeue()); if(typeof(T4) == typeof(long))re.d = long.Parse(input.Dequeue()); if(typeof(T4) == typeof(ulong))re.d = ulong.Parse(input.Dequeue()); if(typeof(T4) == typeof(float))re.d = float.Parse(input.Dequeue()); if(typeof(T4) == typeof(double))re.d = double.Parse(input.Dequeue()); return ((T1,T2,T3,T4))re; } /// /// If 'grid[ i , j ]' matches 'subject', its coordinate will be listed to list. /// /// /// /// /// /// /// /// public static T AssignGrid(int h,int w,bool makeEdge = false){ object re = null; if(typeof(T) == typeof(char[][]) && makeEdge==true){ char[][] grid = new char[h+2][]; grid[0]=new char[w+2]; grid[h+1]=new char[w+2]; for(int i = 1;i<=h;i++){ grid[i] = new char[w+2]; char[] c = Console.ReadLine().ToCharArray(); for(int j = 1;j<=w;j++){ grid[i][j]=c[j-1]; } } re = grid; } if(typeof(T) == typeof(char[][]) && makeEdge!=true){ char[][] grid = new char[h][]; for(int i = 0;i ListUp(char[][] g,char targ){ int h = g.Length; int w = g[0].Length; var l = new List<(int,int)>(); for(int i = 0;i ListUp(int[][] g,int targ){ int h = g.Length; int w = g[0].Length; var l = new List<(int,int)>(); for(int i = 0;i(int size1,int size2){ T[][] c = new T[size1][]; for(int i = 0;i