Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action — multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k.

The first line contains a single integer k (2 ≤ k ≤ 10) — the radix of the system.

Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity).

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class MultiplicationTable {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int k = sc.nextInt();
		for (int i = 1; i <= k-1; i++) {
			for (int j = 1; j <= k-1; j++) {
				if (j > 1)
					out.print(" ");
				BigInteger I = new BigInteger(i+"", k), J = new BigInteger(j+"", k);
				out.print(I.multiply(J).toString(k));
			}
			out.println();
		}

		out.flush();
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(FileReader f) {
			br = new BufferedReader(f);
		}

		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean Ready() throws IOException {
			return br.ready();
		}

		public void waitForInput(long time) {
			long ct = System.currentTimeMillis();
			while(System.currentTimeMillis() - ct < time) {};
		}

	}

}

import java.util.*;
import java.math.*;

public class MTable
{
	public static int decToRad(int n, int r)
	{
		String s = new String();
		int t, k;

		while(n > 0)
		{
			t = n % r;
			n /= r;
			s = t + s;
		}

		return Integer.parseInt(s);
	}

	public static void display(int n)
	{
		for(int i = 1; i < n; ++i)
			for(int j = 1; j < n; ++j)
			{
				if(j + 1 < n)
					System.out.print(decToRad(i * j, n) + " ");
				else
					System.out.println(decToRad(i * j, n));
			}
	}

	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();

		display(n);
	}
}

import java.math.*;
import java.util.*;

public class H{
  public static void main(String[] args) {

    Scanner in = new Scanner(System.in);

    int radix = in.nextInt();
    in.close();

    for(int i = 1; i < radix; i++){
      for(int j = 1; j < radix; j++){
        System.out.print(Integer.toString(i*j, radix) + " ");
      }
      System.out.println();
    }

    System.exit(0);
  }
}

import java.util.Scanner;

public class H39 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		for (int i=1;i<k;i++) { System.out.print(i+"  "); } System.out.println();
		for (int i=2;i<k;i++) {
			System.out.print(i+" ");
			for(int j=2;j<k;j++) {
				int z = i*j;
				int q = 0;
				if (z>=k) {
					for (int w=1;z>0;w++) {
						q = q*10;
						q += (z%k);
						z = z/k;
					} q = (q%10)*10+q/10;
				} else q=z;
				if (q<10) { System.out.print(" "+q+" "); } else { System.out.print(q+" ");}
			}
			System.out.println();
		}
	}

}

import java.util.*;
import java.io.*;

public class aaaaaaaaaaaaaaaa {
	public void run() throws Exception {
		FastReader file = new FastReader();
		int times = file.nextInt();
		String[][] mat = new String[times-1][times-1];
		for (int i = 0; i < times-1; i++) {
			for (int j = 0; j < times - 1; j++) {
				mat[i][j] = Integer.toString((i + 1) * (j + 1), times);
			}
		}
		for (String[] i : mat) {
			for (String a : i) {
				System.out.print(a + " ");
			}
			System.out.println();
		}
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author John Martin
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        HMultiplicationTable solver = new HMultiplicationTable();
        solver.solve(1, in, out);
        out.close();
    }

    static class HMultiplicationTable {
        public void solve(int testNumber, InputReader c, OutputWriter w) {
            int k = c.readInt();
            int cur = 1;
            for (int i = 1; i < k; i++) {
                for (int j = 1; j < k; j++) {
                    int pt = i * j;
                    w.print(Integer.toString(pt, k) + " ");
                }
                w.printLine();
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine() {
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}

import java.io.*;
import java.util.*;

/**
 * Created by Dasha on 05.12.2015.
 */
public class Solution {
    Scanner scanner;

    public static void main(String[] args) throws IOException {
        new Solution().run();

    }

    void run() throws IOException {

        scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int k = scanner.nextInt();
        int a[][] = new int[k - 1][k - 1];

        for (int i = 0; i < k - 1; i++) {
            for (int j = 0; j < k - 1; j++) {
                a[i][j] = (j + 1) * (i + 1);
                System.out.print(func(a[i][j], k) + " ");
            }
            System.out.println();
        }

        out.close();
    }

    int func(int ch, int osn) {
        String s = "";
        while (ch >= osn) {
            s += ch % osn;
            ch = ch / osn;
        }
        s += ch;
        String ans = new StringBuilder(s).reverse().toString();
        return Integer.parseInt(ans);
    }
}

import java.util.*;

public class Main {

public static void main(String... args) {

Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i=1; i<n; i++){
  for (int j=1; j<n; j++){
    System.out.print(Integer.toString(i*j,n)+" ");
}
System.out.println();
}

}
}

import java.util.*;
import java.io.*;
	public class yahia {
		static int n ;
		public static void main (String [] Yahia_Mostafa) throws Exception {
			Scanner sc =new Scanner(System.in);
			 n =sc.nextInt();
			StringBuilder sBuilder=new StringBuilder();
			for (int i =1;i<=n-1;++i) {
				for (int j =1 ;j<n;++j) {
					sBuilder.append(convert(i*j)+" ");
				}
				sBuilder.append("\n");
			}
			System.out.println(sBuilder);
		}
		static StringBuilder convert (int num) {
			StringBuilder x =new StringBuilder();
			while (num>0) {
				x.append(num%n);
				num/=n;
			}
			return x.reverse();
		}
		static class Scanner {
			StringTokenizer stringTokenizer;
			BufferedReader bfBufferedReader;
			public Scanner(InputStream system) {
				bfBufferedReader=new BufferedReader(new InputStreamReader( system));
			}
			 public Scanner(String file) throws Exception {
		            bfBufferedReader = new BufferedReader(new FileReader( file));
		        }

		        public String next() throws IOException {
		            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens())
		                stringTokenizer = new StringTokenizer( bfBufferedReader.readLine());
		            return stringTokenizer.nextToken();
		        }

		        public String nextLine() throws IOException {
		            return bfBufferedReader.readLine();
		        }

		        public int nextInt() throws IOException {
		            return Integer.parseInt(next());
		        }

		        public double nextDouble() throws IOException {
		            return Double.parseDouble(next());
		        }

		        public char nextChar() throws IOException {
		            return next().charAt(0);
		        }

		        public Long nextLong() throws IOException {
		            return Long.parseLong(next());
		        }

		        public boolean ready() throws IOException {
		            return bfBufferedReader.ready();
		        }

		        public void waitForInput() throws InterruptedException {
		            Thread.sleep(3000);
		        }
		    }
		}

import java.io.*;
import java.util.*;
import java.math.*;
public class Solution
{
   BufferedReader in;
   PrintWriter out;
   StringTokenizer ss;

String _token()throws IOException
{
   while (!ss.hasMoreTokens())ss=new StringTokenizer(in.readLine());
   return ss.nextToken();
}
int _int()throws IOException{return Integer.parseInt(_token());}
long _long()throws IOException{return Long.parseLong(_token());}
double _double()throws IOException{return Double.parseDouble(_token());}
void dbg(String s){System.out.println(s);}

BigInteger ad(BigInteger A, BigInteger B){return (A.add(B));}
BigInteger mu(BigInteger A, BigInteger B){return (A.multiply(B));}
BigInteger su(BigInteger A, BigInteger B){return (A.subtract(B));}
BigInteger di(BigInteger A, BigInteger B){return A.divide(B);}
BigInteger mi(BigInteger A){return (BigInteger.ZERO).subtract(A);}
BigInteger sq(BigInteger A){return (A.multiply(A));}
BigInteger va(long a){return BigInteger.valueOf(a);}

BigDecimal val(double a){return BigDecimal.valueOf(a);};
BigDecimal mult(BigDecimal a, BigDecimal b){return a.multiply(b);}
BigDecimal div(BigDecimal a, BigDecimal b){return a.divide(b,30,RoundingMode.CEILING);}
BigDecimal add(BigDecimal a, BigDecimal b){return a.add(b);}
BigDecimal sub(BigDecimal a, BigDecimal b){return a.subtract(b);}

void RUN()throws IOException
{
   in = new BufferedReader(new InputStreamReader(System.in));
   out = new PrintWriter(System.out);
   ss = new StringTokenizer(" ");

   int n = _int();

   for(int i=1;i<n;i++)
     {for(int j=1;j<n;j++)
       {
         BigInteger a = new BigInteger(i+"",n);
         BigInteger b = new BigInteger(j+"",n);
         out.print(mu(a,b).toString(n)+" ");

       }
       out.println();
     }
   out.close();
}

public static void main(String[] args)throws Exception
  {
     new Solution().RUN();
  }
}

import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

@SuppressWarnings("unchecked")
public class P39H {

  public void run() throws Exception {
    int k = nextInt();

    for (int i = 1; i < k; i++) {
      for (int j = 1; j < k; j++) {
        print(Integer.toString(i * j, k) + " ");
      }

      println();
    }
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P39H().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Integer.numberOfTrailingZeros(a), bz = Integer.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Integer.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Integer.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  long gcd(long a, long b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Long.numberOfTrailingZeros(a), bz = Long.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Long.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Long.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
//import java.util.StringTokenizer;
import java.lang.StringBuilder;
//import java.util.Arrays;
//import java.util.HashMap;
//import java.util.ArrayList;

public class MultiplicationTable {

    static int b;
    static StringBuilder sb = new StringBuilder();
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        b = Integer.parseInt(in.readLine());
        int n = b-1;
        String[][] str = new String[n][n];
        if(b == 10)
            for(int i = 0; i < n; i++) {
                for(int j = 0; j < n; j++) {
                    str[i][j] = "" + ((i+1) * (j+1));
                }
            }
        else
            for(int i = 0; i < n; i++) {
                for(int j = 0; j < n; j++) {
                    str[i][j] = convertir((i+1) * (j+1));
                }
            }
        int l = str[n-1][n-1].length() + 1;
        for(int i = 0; i < n; i++) {
            sb.append(str[i][0]);
            for(int j = 1; j < n; j++) {
                ajouter(l - str[i][j].length());
                sb.append(str[i][j]);
            }
            sb.append("\n");
        }
        out.print(sb);
        out.close();
    }

    public static void ajouter(int n) {
        for(int i = 0; i < n; i++) {
            sb.append(" ");
        }
    }

    public static String convertir(int n) {
        StringBuilder s = new StringBuilder();
        while(n != 0) {
            s.append((n % b));
            n = (n / b);
        }
        return s.reverse().toString();
    }
}

import java.util.*;

public class MultiplicationTable {
	public static void main(String[] args){
		Scanner reader = new Scanner(System.in);
		int r = reader.nextInt();
		for(int i = 1; i < r; i++){
			for(int j = 1; j < r; j++){
				System.out.print(Integer.toString(i*j,r) + " ");
			}
			System.out.println();
		}
	}
}

import java.util.*;
public class susbus{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int k =sc.nextInt();
      int [][] result = new int[k-1][k-1];
      for (int i=0;i<k-1;i++){
         for (int j=0;j<k-1;j++){
          result[i][j]=(i+1)*(j+1);

         }
      }
      for (int i=0;i<k-1;i++){
         for (int j=0;j<k-1;j++){
            result[i][j] = convertBase(result[i][j],k);
         }
      }
      for (int i = 0; i < k-1; i++) {
    for (int j = 0; j < k-1; j++) {
        System.out.print(result[i][j] + " ");
    }
    System.out.println();
}

   }
   public static int convertBase(int n, int base){
      String nibbas = "";
      while(n>0){
         nibbas+=n%base;
         n=n/base;
      }
      String bibba = "";
      for (int i=0;i<nibbas.length();i++){
         bibba+=nibbas.charAt(nibbas.length()-i-1);
      }
      return Integer.parseInt(bibba);
   }
}

import java.io.*;
import java.util.*;

public class NewClass {

    public static int inde(int[] a) {
        int inde = 0, elem = a[0];
        for (int i = 1; i < a.length; i++) {
            if (a[i] < elem) {
                elem = a[i];
                inde = i;
            }
        }
        return inde;
    }

    public static int min(int... a) {
        int su = a[0];
        for (int i = 1; i < a.length; i++) {
            if (a[i] > su) {
                su = a[i];
            }
        }
        return su;
    }

    public static String Radix(int num,int a){
        StringBuilder ans=new StringBuilder();
        while(num>0){
            ans.append(num%a);
            num/=a;
        }
                return ans.reverse().toString();
    }

    public static int[] fibname(int n, int[] a) {
        long[] b = new long[n + 1];
        a[1] = a[2] = 1;
        b[1] = b[2] = 1;

        for (int i = 3; i <= n; i++) {
            b[i] = b[i - 1] + b[i - 2];
            if (n >= b[i]) {
                a[(int) b[i]] = (int) b[i];
            } else {
                break;
            }
        }
        return a;
    }

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        int n = in.nextInt();
        for (int i = 1; i < n; i++) {
            for (int k = 1; k < n; k++) {
                out.print(Radix(i*k, n));
                        if (k!=n-1) out.print(" ");
                        else out.printLine();
            }
        }
        out.flush();

    }
}

class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (snumChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

}

class OutputWriter {

    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                writer.print(' ');
            }
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

    public void flush() {
        writer.flush();
    }

}

import java.util.*;
import java.io.*;

public class Main implements Runnable {

	public void solve() throws IOException {
		int N = nextInt();
                for(int i = 1; i < N; i++){
                    for(int j = 1; j < N; j++){
                        out.print(changeBase(i * j, N) + " ");
                    }
                    out.println();
                }
	}

        private String changeBase(int n, int base){
            StringBuilder ans = new StringBuilder();
            while(n > 0){
                ans.append(n % base);
                n = n / base;
            }

            return ans.reverse().toString();
        }

	//-----------------------------------------------------------
	public static void main(String[] args) {
		new Main().run();
	}

        public void debug(Object... arr){
            System.out.println(Arrays.deepToString(arr));
        }

        public void print1Int(int[] a){
                for(int i = 0; i < a.length; i++)
                        System.out.print(a[i] + " ");
                System.out.println();
        }

        public void print2Int(int[][] a){
                for(int i = 0; i < a.length; i++){
                        for(int j = 0; j < a[0].length; j++){
                                System.out.print(a[i][j] + " ");
                        }
                        System.out.println();
                }
        }

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
			tok = null;
			solve();
			in.close();
                        out.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

	public String nextToken() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
        PrintWriter out;
	BufferedReader in;
	StringTokenizer tok;
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class H {

	static class Scanner{
		BufferedReader br=null;
		StringTokenizer tk=null;
		public Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() throws IOException{
			while(tk==null || !tk.hasMoreTokens())
				tk=new StringTokenizer(br.readLine());
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException{
			return Integer.valueOf(next());
		}
		public double nextDouble() throws NumberFormatException, IOException{
			return Double.valueOf(next());
		}
	}

	public static void main(String args[]) throws NumberFormatException, IOException{
		Scanner sc =  new Scanner();
		int K = sc.nextInt();
		int[] base = new int[K - 1];
		for(int i = 0; i < K - 1; i++)
			base[i] = i + 1;
		for(int m = 1; m < K; m++){
			for(int j = 0; j < K - 1; j++)
				System.out.print(Integer.toString(base[j] * m, K)+ " ");
			System.out.println();
		}
	}

}

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.regex.Matcher;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Zyflair Griffane
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		PandaScanner in = new PandaScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		H solver = new H();
		solver.solve(1, in, out);
		out.close();
	}
}

class H {
    public void solve(int testNumber, PandaScanner in, PrintWriter out) {
        int n = in.nextInt();
        StringBuilder res = new StringBuilder();
        for (int i = 1; i < n; i++) {
            for (int j = 1; j < n; j++) {
                res.append(Integer.toString(i * j, n) + "  ");
            }
            res.setLength(res.length() - 1);
            res.append("\n");
        }
        Pattern regex = Pattern.compile(" (\\d\\d)");
        Matcher regexMatcher = regex.matcher(res.toString());
        String str = regexMatcher.replaceAll("$1");
        out.println(str);
    }
}

class PandaScanner {
    public BufferedReader br;
    public StringTokenizer st;
    public InputStream in;

    public PandaScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(this.in = in));
    }

    public String nextLine() {
        try {
            return br.readLine();
        }
        catch (Exception e) {
            return null;
        }
    }

    public String next() {
        if (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(nextLine().trim());
            return next();
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF_39_H_MULTIPLICATION_TABLE {

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner (System.in);
		int k = sc.nextInt();

		for(int i = 1 ; i<k ;i++) {
			for(int j = 1 ; j < k ;j++)
				System.out.print(Integer.toString(i*j,k)+" ");
			System.out.println();
		}

	}
	static class Scanner {
		BufferedReader bf;
		StringTokenizer st;

		public Scanner(InputStream i) {
			bf = new BufferedReader(new InputStreamReader(i));

		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(bf.readLine());
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}
}

import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        int[][]table = new int[N-1][N-1];
        for (int i = 0; i<N-1; i++){
            table[i][0] = i+1;
            table[0][i] = i+1;
        }

        for (int i = 0; i<N-1; i++){
            for (int j = 0; j<N-1; j++){
                table[i][j] = main.toSystem(main.toDEC(table[i][0], N) * main.toDEC(table[0][j], N), N);
                System.out.print(table[i][j]+" ");
            }System.out.println();
        }
    }
    int toSystem(int A, int n){
        String S = "";
        int k = 0;
        while (A>0){
            k = A%n;
            A = A/n;
            S = k + S;
        }
        A = Integer.parseInt(S);
        return A;
    }

    int toDEC(int A, int n){
        int l = 0;
        int DEC = 0;
        while (A>0){
            DEC = DEC + A%10 * (int)Math.pow(n, l);
            l++;
            A = A/10;
        }
        return DEC;
    }
}

import java.util.Scanner;

/**
 * Created by max_b on 2/1/2017.
 */
public class driver {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        for(int i = 1; i<n; i++){

            for(int o = 1; o<n; o++){
                Integer p = i*o;
                String q = Integer.toString(p, n);
                System.out.print(q+" ");
            }
            System.out.println();
        }
    }
}

public class H {
	public static void main(String[] args) {
		int n = new java.util.Scanner(System.in).nextInt();
		for (int i = 1; i < n; ++i) {
			for (int j = 1; j < n; ++j) {
				System.out.print(Integer.toString(i * j, n) + " ");
			}
			System.out.println();
		}
	}
}

/*
 * Hello! You are trying to hack my solution, are you? =)
 * Don't be afraid of the size, it's just a dump of useful methods like gcd, or n-th Fib number.
 * And I'm just to lazy to create a new .java for every task.
 * And if you were successful to hack my solution, please, send me this test as a message or to Abrackadabraa@gmail.com.
 * It can help me improve my skills and i'd be very grateful for that.
 * Sorry for time you spent reading this message. =)
 * Good luck, unknown rival. =)
 * */

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import java.util.Vector;

public class Abra {
	public static void main(String[] args) throws IOException {
		new Abra().run();
	}

	static class myLib {
		long fact(long x) {
			long a = 1;
			for (long i = 2; i <= x; i++) {
				a *= i;
			}
			return a;
		}

		long digitSum(String x) {
			long a = 0;
			for (int i = 0; i < x.length(); i++) {
				a += x.charAt(i) - '0';
			}
			return a;
		}

		long digitSum(long x) {
			long a = 0;
			while (x > 0) {
				a += x % 10;
				x /= 10;
			}
			return a;
		}

		long digitMul(long x) {
			long a = 1;
			while (x > 0) {
				a *= x % 10;
				x /= 10;
			}
			return a;
		}

		int digitCubesSum(int x) {
			int a = 0;
			while (x > 0) {
				a += (x % 10) * (x % 10) * (x % 10);
				x /= 10;
			}
			return a;
		}

		double pif(double ax, double ay, double bx, double by) {
			return Math.sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
		}

		long gcd(long a, long b) {
			if (a == 0 || b == 0) return 1;
			if (a < b) {
				long c = b;
				b = a;
				a = c;
			}
			while (a % b != 0) {
				a = a % b;
				if (a < b) {
					long c = b;
					b = a;
					a = c;
				}
			}
			return b;
		}

		int gcd(int a, int b) {
			if (a == 0 || b == 0) return 1;
			if (a < b) {
				int c = b;
				b = a;
				a = c;
			}
			while (a % b != 0) {
				a = a % b;
				if (a < b) {
					int c = b;
					b = a;
					a = c;
				}
			}
			return b;
		}

		long lcm(long a, long b) throws IOException {
			return a * b / gcd(a, b);
		}

		int lcm(int a, int b) throws IOException {
			return a * b / gcd(a, b);
		}

		int countOccurences(String x, String y) {
			int a = 0, i = 0;
			while (true) {
				i = y.indexOf(x);
				if (i == -1) break;
				a++;
				y = y.substring(i + 1);
			}
			return a;
		}

		int[] findPrimes(int x) {
			boolean[] forErato = new boolean[x - 1];
			List<Integer> t = new Vector<Integer>();
			int l = 0, j = 0;
			for (int i = 2; i < x; i++) {
				if (forErato[i - 2]) continue;
				t.add(i);
				l++;
				j = i * 2;
				while (j < x) {
					forErato[j - 2] = true;
					j += i;
				}
			}
			int[] primes = new int[l];
			Iterator<Integer> iterator = t.iterator();
			for (int i = 0; iterator.hasNext(); i++) {
				primes[i] = iterator.next().intValue();
			}
			return primes;
		}

		int rev(int x) {
			int a = 0;
			while (x > 0) {
				a = a * 10 + x % 10;
				x /= 10;
			}
			return a;
		}

		class myDate {
			int d, m, y;

			int[] ml = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

			public myDate(int da, int ma, int ya) {
				d = da;
				m = ma;
				y = ya;
				if ((ma > 12 || ma < 1 || da > ml[ma - 1] || da < 1) && !(d == 29 && m == 2 && y % 4 == 0)) {
					d = 1;
					m = 1;
					y = 9999999;
				}
			}

			void incYear(int x) {
				for (int i = 0; i < x; i++) {
					y++;
					if (m == 2 && d == 29) {
						m = 3;
						d = 1;
						return;
					}
					if (m == 3 && d == 1) {
						if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) {
							m = 2;
							d = 29;
						}
						return;
					}
				}
			}

			boolean less(myDate x) {
				if (y < x.y) return true;
				if (y > x.y) return false;
				if (m < x.m) return true;
				if (m > x.m) return false;
				if (d < x.d) return true;
				if (d > x.d) return false;
				return true;
			}

			void inc() {
				if ((d == 31) && (m == 12)) {
					y++;
					d = 1;
					m = 1;
				} else {
					if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) {
						ml[1] = 29;
					}
					if (d == ml[m - 1]) {
						m++;
						d = 1;
					} else
						d++;
				}
			}
		}

		int partition(int n, int l, int m) {// n - sum, l - length, m - every
											// part
			// <= m
			if (n < l) return 0;
			if (n < l + 2) return 1;
			if (l == 1) return 1;
			int c = 0;
			for (int i = Math.min(n - l + 1, m); i >= (n + l - 1) / l; i--) {
				c += partition(n - i, l - 1, i);
			}
			return c;
		}

		int rifmQuality(String a, String b) {
			if (a.length() > b.length()) {
				String c = a;
				a = b;
				b = c;
			}
			int c = 0, d = b.length() - a.length();
			for (int i = a.length() - 1; i >= 0; i--) {
				if (a.charAt(i) == b.charAt(i + d)) c++;
				else
					break;
			}
			return c;
		}

		String numSym = "0123456789ABCDEF";

		String ZFromXToYNotation(int x, int y, String z) {
			if (z.equals("0")) return "0";
			String a = "";
			long q = 0, t = 1;
			for (int i = z.length() - 1; i >= 0; i--) {
				q += (z.charAt(i) - 48) * t;
				t *= x;
			}
			while (q > 0) {
				a = numSym.charAt((int) (q % y)) + a;
				q /= y;
			}
			return a;
		}

		double angleFromXY(int x, int y) {
			if ((x == 0) && (y > 0)) return Math.PI / 2;
			if ((x == 0) && (y < 0)) return -Math.PI / 2;
			if ((y == 0) && (x > 0)) return 0;
			if ((y == 0) && (x < 0)) return Math.PI;
			if (x > 0) return Math.atan((double) y / x);
			else {
				if (y > 0) return Math.atan((double) y / x) + Math.PI;
				else
					return Math.atan((double) y / x) - Math.PI;
			}
		}

		static boolean isNumber(String x) {
			try {
				Integer.parseInt(x);
			} catch (NumberFormatException ex) {
				return false;
			}
			return true;
		}

		static boolean stringContainsOf(String x, String c) {
			for (int i = 0; i < x.length(); i++) {
				if (c.indexOf(x.charAt(i)) == -1) return false;
			}
			return true;
		}

		long pow(long a, long n) { // b > 0
			if (n == 0) return 1;
			long k = n, b = 1, c = a;
			while (k != 0) {
				if (k % 2 == 0) {
					k /= 2;
					c *= c;
				} else {
					k--;
					b *= c;
				}
			}
			return b;
		}

		int pow(int a, int n) { // b > 0
			if (n == 0) return 1;
			int k = n, b = 1, c = a;
			while (k != 0) {
				if (k % 2 == 0) {
					k /= 2;
					c *= c;
				} else {
					k--;
					b *= c;
				}
			}
			return b;
		}

		double pow(double a, int n) { // b > 0
			if (n == 0) return 1;
			double k = n, b = 1, c = a;
			while (k != 0) {
				if (k % 2 == 0) {
					k /= 2;
					c *= c;
				} else {
					k--;
					b *= c;
				}
			}
			return b;
		}

		double log2(double x) {
			return Math.log(x) / Math.log(2);
		}

		int lpd(int[] primes, int x) {// least prime divisor
			int i;
			for (i = 0; primes[i] <= x / 2; i++) {
				if (x % primes[i] == 0) {
					return primes[i];
				}
			}
			;
			return x;
		}

		int np(int[] primes, int x) {// number of prime number
			for (int i = 0; true; i++) {
				if (primes[i] == x) return i;
			}
		}

		int[] dijkstra(int[][] map, int n, int s) {
			int[] p = new int[n];
			boolean[] b = new boolean[n];
			Arrays.fill(p, Integer.MAX_VALUE);
			p[s] = 0;
			b[s] = true;
			for (int i = 0; i < n; i++) {
				if (i != s) p[i] = map[s][i];
			}
			while (true) {
				int m = Integer.MAX_VALUE, mi = -1;
				for (int i = 0; i < n; i++) {
					if (!b[i] && (p[i] < m)) {
						mi = i;
						m = p[i];
					}
				}
				if (mi == -1) break;
				b[mi] = true;
				for (int i = 0; i < n; i++)
					if (p[mi] + map[mi][i] < p[i]) p[i] = p[mi] + map[mi][i];
			}
			return p;
		}

		boolean isLatinChar(char x) {
			if (((x >= 'a') && (x <= 'z')) || ((x >= 'A') && (x <= 'Z'))) return true;
			else
				return false;
		}

		boolean isBigLatinChar(char x) {
			if (x >= 'A' && x <= 'Z') return true;
			else
				return false;
		}

		boolean isSmallLatinChar(char x) {
			if (x >= 'a' && x <= 'z') return true;
			else
				return false;
		}

		boolean isDigitChar(char x) {
			if (x >= '0' && x <= '9') return true;
			else
				return false;
		}

		class NotANumberException extends Exception {
			private static final long serialVersionUID = 1L;
			String mistake;

			NotANumberException() {
				mistake = "Unknown.";
			}

			NotANumberException(String message) {
				mistake = message;
			}
		}

		class Real {
			String num = "0";
			long exp = 0;
			boolean pos = true;

			long length() {
				return num.length();
			}

			void check(String x) throws NotANumberException {
				if (!stringContainsOf(x, "0123456789+-.eE")) throw new NotANumberException("Illegal character.");
				long j = 0;
				for (long i = 0; i < x.length(); i++) {
					if ((x.charAt((int) i) == '-') || (x.charAt((int) i) == '+')) {
						if (j == 0) j = 1;
						else
							if (j == 5) j = 6;
							else
								throw new NotANumberException("Unexpected sign.");
					} else
						if ("0123456789".indexOf(x.charAt((int) i)) != -1) {
							if (j == 0) j = 2;
							else
								if (j == 1) j = 2;
								else
									if (j == 2)
									;
									else
										if (j == 3) j = 4;
										else
											if (j == 4)
											;
											else
												if (j == 5) j = 6;
												else
													if (j == 6)
													;
													else
														throw new NotANumberException("Unexpected digit.");
						} else
							if (x.charAt((int) i) == '.') {
								if (j == 0) j = 3;
								else
									if (j == 1) j = 3;
									else
										if (j == 2) j = 3;
										else
											throw new NotANumberException("Unexpected dot.");
							} else
								if ((x.charAt((int) i) == 'e') || (x.charAt((int) i) == 'E')) {
									if (j == 2) j = 5;
									else
										if (j == 4) j = 5;
										else
											throw new NotANumberException("Unexpected exponent.");
								} else
									throw new NotANumberException("O_o.");
				}
				if ((j == 0) || (j == 1) || (j == 3) || (j == 5)) throw new NotANumberException("Unexpected end.");
			}

			public Real(String x) throws NotANumberException {
				check(x);
				if (x.charAt(0) == '-') pos = false;
				long j = 0;
				String e = "";
				boolean epos = true;
				for (long i = 0; i < x.length(); i++) {
					if ("0123456789".indexOf(x.charAt((int) i)) != -1) {
						if (j == 0) num += x.charAt((int) i);
						if (j == 1) {
							num += x.charAt((int) i);
							exp--;
						}
						if (j == 2) e += x.charAt((int) i);
					}
					if (x.charAt((int) i) == '.') {
						if (j == 0) j = 1;
					}
					if ((x.charAt((int) i) == 'e') || (x.charAt((int) i) == 'E')) {
						j = 2;
						if (x.charAt((int) (i + 1)) == '-') epos = false;
					}
				}
				while ((num.length() > 1) && (num.charAt(0) == '0'))
					num = num.substring(1);
				while ((num.length() > 1) && (num.charAt(num.length() - 1) == '0')) {
					num = num.substring(0, num.length() - 1);
					exp++;
				}
				if (num.equals("0")) {
					exp = 0;
					pos = true;
					return;
				}
				while ((e.length() > 1) && (e.charAt(0) == '0'))
					e = e.substring(1);
				try {
					if (e != "") if (epos) exp += Long.parseLong(e);
					else
						exp -= Long.parseLong(e);
				} catch (NumberFormatException exc) {
					if (!epos) {
						num = "0";
						exp = 0;
						pos = true;
					} else {
						throw new NotANumberException("Too long exponent");
					}
				}
			}

			public Real() {
			}

			String toString(long mantissa) {
				String a = "", b = "";
				if (exp >= 0) {
					a = num;
					if (!pos) a = '-' + a;
					for (long i = 0; i < exp; i++)
						a += '0';
					for (long i = 0; i < mantissa; i++)
						b += '0';
					if (mantissa == 0) return a;
					else
						return a + "." + b;
				} else {
					if (exp + length() <= 0) {
						a = "0";
						if (mantissa == 0) {
							return a;
						}
						if (mantissa < -(exp + length() - 1)) {
							for (long i = 0; i < mantissa; i++)
								b += '0';
							return a + "." + b;
						} else {
							if (!pos) a = '-' + a;
							for (long i = 0; i < mantissa; i++)
								if (i < -(exp + length())) b += '0';
								else
									if (i + exp >= 0) b += '0';
									else
										b += num.charAt((int) (i + exp + length()));
							return a + "." + b;
						}
					} else {
						if (!pos) a = "-";
						for (long i = 0; i < exp + length(); i++)
							a += num.charAt((int) i);
						if (mantissa == 0) return a;
						for (long i = exp + length(); i < exp + length() + mantissa; i++)
							if (i < length()) b += num.charAt((int) i);
							else
								b += '0';
						return a + "." + b;
					}
				}
			}
		}

		boolean containsRepeats(int... num) {
			Set<Integer> s = new TreeSet<Integer>();
			for (int d : num)
				if (!s.contains(d)) s.add(d);
				else
					return true;
			return false;
		}

		int[] rotateDice(int[] a, int n) {
			int[] c = new int[6];
			if (n == 0) {
				c[0] = a[1];
				c[1] = a[5];
				c[2] = a[2];
				c[3] = a[0];
				c[4] = a[4];
				c[5] = a[3];
			}
			if (n == 1) {
				c[0] = a[2];
				c[1] = a[1];
				c[2] = a[5];
				c[3] = a[3];
				c[4] = a[0];
				c[5] = a[4];
			}
			if (n == 2) {
				c[0] = a[3];
				c[1] = a[0];
				c[2] = a[2];
				c[3] = a[5];
				c[4] = a[4];
				c[5] = a[1];
			}
			if (n == 3) {
				c[0] = a[4];
				c[1] = a[1];
				c[2] = a[0];
				c[3] = a[3];
				c[4] = a[5];
				c[5] = a[2];
			}
			if (n == 4) {
				c[0] = a[0];
				c[1] = a[2];
				c[2] = a[3];
				c[3] = a[4];
				c[4] = a[1];
				c[5] = a[5];
			}
			if (n == 5) {
				c[0] = a[0];
				c[1] = a[4];
				c[2] = a[1];
				c[3] = a[2];
				c[4] = a[3];
				c[5] = a[5];
			}
			return c;
		}

		int min(int... a) {
			int c = Integer.MAX_VALUE;
			for (int d : a)
				if (d < c) c = d;
			return c;
		}

		int max(int... a) {
			int c = Integer.MIN_VALUE;
			for (int d : a)
				if (d > c) c = d;
			return c;
		}

		int[] normalizeDice(int[] a) {
			int[] c = a.clone();
			if (c[0] != 0) if (c[1] == 0) c = rotateDice(c, 0);
			else
				if (c[2] == 0) c = rotateDice(c, 1);
				else
					if (c[3] == 0) c = rotateDice(c, 2);
					else
						if (c[4] == 0) c = rotateDice(c, 3);
						else
							if (c[5] == 0) c = rotateDice(rotateDice(c, 0), 0);
			while (c[1] != min(c[1], c[2], c[3], c[4]))
				c = rotateDice(c, 4);
			return c;
		}

		boolean sameDice(int[] a, int[] b) {
			for (int i = 0; i < 6; i++)
				if (a[i] != b[i]) return false;
			return true;
		}

		final double goldenRatio = (1 + Math.sqrt(5)) / 2;
		final double aGoldenRatio = (1 - Math.sqrt(5)) / 2;

		long Fib(int n) {
			if (n < 0) if (n % 2 == 0) return -Math.round((pow(goldenRatio, -n) - pow(aGoldenRatio, -n)) / Math.sqrt(5));
			else
				return -Math.round((pow(goldenRatio, -n) - pow(aGoldenRatio, -n)) / Math.sqrt(5));
			return Math.round((pow(goldenRatio, n) - pow(aGoldenRatio, n)) / Math.sqrt(5));
		}

		class japaneeseComparator implements Comparator<String> {
			@Override
			public int compare(String a, String b) {
				int ai = 0, bi = 0;
				boolean m = false, ns = false;
				if (a.charAt(ai) <= '9' && a.charAt(ai) >= '0') {
					if (b.charAt(bi) <= '9' && b.charAt(bi) >= '0') m = true;
					else
						return -1;
				}
				if (b.charAt(bi) <= '9' && b.charAt(bi) >= '0') {
					if (a.charAt(ai) <= '9' && a.charAt(ai) >= '0') m = true;
					else
						return 1;
				}
				a += "!";
				b += "!";
				int na = 0, nb = 0;
				while (true) {
					if (a.charAt(ai) == '!') {
						if (b.charAt(bi) == '!') break;
						return -1;
					}
					if (b.charAt(bi) == '!') {
						return 1;
					}
					if (m) {
						int ab = -1, bb = -1;
						while (a.charAt(ai) <= '9' && a.charAt(ai) >= '0') {
							if (ab == -1) ab = ai;
							ai++;
						}
						while (b.charAt(bi) <= '9' && b.charAt(bi) >= '0') {
							if (bb == -1) bb = bi;
							bi++;
						}
						m = !m;
						if (ab == -1) {
							if (bb == -1) continue;
							else
								return 1;
						}
						if (bb == -1) return -1;
						while (a.charAt(ab) == '0' && ab + 1 != ai) {
							ab++;
							if (!ns) na++;
						}
						while (b.charAt(bb) == '0' && bb + 1 != bi) {
							bb++;
							if (!ns) nb++;
						}
						if (na != nb) ns = true;
						if (ai - ab < bi - bb) return -1;
						if (ai - ab > bi - bb) return 1;
						for (int i = 0; i < ai - ab; i++) {
							if (a.charAt(ab + i) < b.charAt(bb + i)) return -1;
							if (a.charAt(ab + i) > b.charAt(bb + i)) return 1;
						}
					} else {
						m = !m;
						while (true) {
							if (a.charAt(ai) <= 'z' && a.charAt(ai) >= 'a' && b.charAt(bi) <= 'z' && b.charAt(bi) >= 'a') {
								if (a.charAt(ai) < b.charAt(bi)) return -1;
								if (a.charAt(ai) > b.charAt(bi)) return 1;
								ai++;
								bi++;
							} else
								if (a.charAt(ai) <= 'z' && a.charAt(ai) >= 'a') return 1;
								else
									if (b.charAt(bi) <= 'z' && b.charAt(bi) >= 'a') return -1;
									else
										break;
						}
					}
				}
				if (na < nb) return 1;
				if (na > nb) return -1;
				return 0;
			}
		}

		Random random = new Random();
	}

	StreamTokenizer in;
	PrintWriter out;
	boolean oj;
	BufferedReader br;

	void init() throws IOException {
		oj = System.getProperty("ONLINE_JUDGE") != null;
		oj = true;
		Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
		Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
		br = new BufferedReader(reader);
		in = new StreamTokenizer(br);
		out = new PrintWriter(writer);
	}

	long selectionTime = 0;

	void startSelection() {
		selectionTime -= System.currentTimeMillis();
	}

	void stopSelection() {
		selectionTime += System.currentTimeMillis();
	}

	void run() throws IOException {
		long beginTime = System.currentTimeMillis();
		init();
		solve();
		long endTime = System.currentTimeMillis();
		if (!oj) {
			System.out.println("Memory used = " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
			System.out.println("Running time = " + (endTime - beginTime));
			System.out.println("Time of the selection = " + selectionTime);
		}
		out.flush();
	}

	int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	long nextLong() throws IOException {
		in.nextToken();
		return (long) in.nval;
	}

	String nextString() throws IOException {
		in.nextToken();
		return in.sval;
	}

	double nextDouble() throws IOException {
		in.nextToken();
		return in.nval;
	}

	myLib lib = new myLib();

	void solve() throws IOException {
		int k = nextInt();
		for (int i = 1; i < k; i++) {
			for (int j = 1; j < k; j++) {
				out.print(lib.ZFromXToYNotation(10, k, Integer.toString(i * j)) + " ");
			}
			out.println();
		}
	}
}

//package school1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class H {

	static StreamTokenizer in =
		new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

	static int nextInt() throws IOException{
		in.nextToken();
		return (int)in.nval;
	}

	static PrintWriter out = new PrintWriter(System.out);

	static void base(int n, int b){
		int res[] = new int[10];
		int l = 0;

		while (n != 0){
			res[l++] = n%b;
			n /= b;
		}

		for (int i=l-1; i>=0; i--)
			out.print(res[i]);
		out.print(' ');
	}

	public static void main(String[] args) throws IOException{
		int k = nextInt();

		for (int i=1; i<k; i++){
			for (int j=1; j<k; j++)
				base(i*j, k);
			out.println();
		}

		out.flush();
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int k = sc.nextInt();
		for(int i = 1; i <= k - 1; ++i)
		{
			for(int j = 1; j <= k - 1; ++j)
				out.print(Integer.toString(i * j, k) + " ");
			out.println();
		}
		out.flush();
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();}
	}
}

import java.util.*;
// warm-up
public class MultiplicationTable {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt();
		for (int i=1; i<k; i++) {
			for (int j=1; j<k; j++) {
				System.out.print(Integer.toString(i*j,k)+" ");
			}
			System.out.println();
		}
		sc.close();
	}

	public static void main(String args[]) {
		solve();
	}

}

import java.util.Scanner;
import java.lang.Math;
public class Ishu
{
    	public static void main(String[] args)
    	{
	 Scanner scan=new Scanner(System.in);
	 int k,i,j,no,e,tem;
	 k=scan.nextInt();
	 for(i=1;i<k;++i)
		{
		 for(j=1;j<k;++j)
			{
			 no=i*j;
			 e=0;
			 tem=0;
			 while(no>0)
				{
				 tem+=(int)Math.pow(10.0,(double)e)*(no%k);
				 ++e;
				 no/=k;
				}
			 System.out.print(tem+" ");
			}
		 System.out.println();
		}
 	}
}

//package school1;

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class H {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		for(int i = 0;i < n - 1;i++){
			for(int j = 0;j < n - 1;j++){
				int v = (i+1)*(j+1);
				out.print(Integer.toString(v, n) + " ");
			}
			out.println();
		}
	}

	void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		solve();
		out.flush();
	}

	public static void main(String[] args) throws Exception
	{
		new H().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	void tr(Object... o) { if(INPUT.length() != 0)System.out.println(o.length > 1 || o[0].getClass().isArray() ? Arrays.deepToString(o) : o[0]); }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Yury Bandarchuk
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();
            for (int i = 1; i < k; i++) {
                for (int j = 1; j < k; j++) {
                    out.print(get(i * j, k));
                    if (j == k - 1) {
                        out.println("");
                    } else {
                        out.print(" ");
                    }
                }
            }
        }

        String get(int val, int base) {
            String result = "";
            while (val > 0) {
                int digit = (val % base);
                result = (char) (digit + 48) + result;
                val /= base;
            }
            return result;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.PrintWriter;
import java.util.Locale;
import java.util.Scanner;

public class H implements Runnable {
    private Scanner in;
    private PrintWriter out;

    private void solve() {
        int k = in.nextInt();
        for (int i = 1; i <= k - 1; ++i) {
            for (int j = 1; j <= k - 1; ++j) {
                out.print("" + (i * j >= k ? i * j / k : "") + (i * j % k) + " ");
            }
            out.println();
        }
    }

    @Override
    public void run() {
        Locale.setDefault(Locale.US);
        in = new Scanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    public static void main(String[] args) {
        new H().run();
    }
}

import java.util.*;

public class Main {

  public static void main(String args[]) {
    (new Main()).solve();
  }

  void solve() {

    Scanner cin = new Scanner(System.in);

    while( cin.hasNextInt() ) {

      int k = cin.nextInt();

      for(int i=1; i<k; ++i) {
        for(int j=1; j<k; ++j) {
          System.out.print(Integer.toString(i * j, k) + " ");
        }
        System.out.println();
      }

    }

  }

}

import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int base = s.nextInt();
        for (int i = 1; i < base; i++) {
            for (int j = 1; j < base; j++) {
                System.out.print(String.format("%s ", Integer.toString(i*j, base)));
            }
            System.out.println();
        }
    }
}

//package com.company;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class H {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int k = sc.nextInt();
        for(int i=1;i<k;i++){
            for(int j=1;j<k;j++){
                System.out.print(Integer.toString(i*j,k)+" ");
            }
            System.out.println();
        }
    }
}

import java.util.Scanner;
public class multiplicationTable {
    public static void main(String[] args) {
        Integer.toString(3, 4); //to convert bases
        Scanner in = new Scanner(System.in);
        int tableSize = in.nextInt();
        in.nextLine();

        for (int i = 1; i < tableSize; i++) {
            for (int j = 1; j < tableSize; j++) {
                System.out.print(Integer.toString(i*j, tableSize) + " ");
            }
            System.out.println(" ");
        }

    }
}

import java.math.*;
import java.util.*;

public class Main {
    public static Scanner in = new Scanner(System.in);
    public static void main(String args[]) {
        int n; n = in.nextInt();
        for (int i = 1; i < n; i++) {
            for (int j = 1; j < n; j++) {
                Long x = (long) i * j;
                System.out.print(Long.toString(x, n));
                System.out.print(" ");
            }
            System.out.println();
        }
    }
}

import java.util.Scanner;

public class H {
    public static String toBase(int x, int b) {
        String res = "";
        while (x > 0) {
            res = x % b + res;
            x /= b;
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 1; i < n; i++) {
            for (int j = 1; j < n; j++)
                System.out.print(toBase(i * j, n) + "   ");
            System.out.println();
        }
    }
}

import java.util.*;
import java.math.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for (int i = 1; i <= n - 1; i++)
		{
			for (int j = 1; j <= n - 1; j++)
			{
				BigInteger temp = new BigInteger(String.valueOf(i * j));

				if (j != n - 1)
					System.out.print(temp.toString(n) + " ");
				else
					System.out.println(temp.toString(n));
			}
		}
	}
}

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class H {

	static int k;

	private static int mult(int x, int y) {
		int m = x * y;
		int r = 0;
		int st = 1;
		while (m != 0) {
			r += (m % k) * st;
			st *= 10;
			m /= k;
		}
		return r;
	}

	/**
	 * @param args
	 * @throws FileNotFoundException
	 */
	public static void main(String[] args) throws FileNotFoundException {
//		Scanner in = new Scanner(new FileInputStream("stdin"));
//		PrintWriter out = new PrintWriter(new FileOutputStream("stdout"));
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		k = in.nextInt();
		for (int i = 1; i < k; i++) {
			for (int j = 1; j < k; j++) {
				if (j != 1) {
					out.print(' ');
				}
				out.print(mult(i, j));
			}
			out.println();
		}

		in.close();
		out.close();
	}

}

import java.util.*;
public class CF39H {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(int i = 0; i < n-1; i ++)
		{
			for(int j = 0; j < n-1; j ++)
				System.out.print(changeBase((i+1)*(j+1), n) + " " );
			System.out.println();
		}
	}
	static long changeBase(int a, int b)
	{
		long ans = 0;
		int pow = 0;
		while(a!=0)
		{
			ans+=(a%b)*Math.pow(10,  pow);
			a/=b;
			pow++;
		}
		return ans;
	}
}

import java.io.*;
import java.util.*;

public class H {
	private static boolean _READ_FROM_FILE = false;
	private static Scanner in;
	private static void core() {
		int n = in.nextInt();
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < n; j++) {
				if (j > 1) System.out.print(" ");
				System.out.print(Integer.toString(i*j, n));
			}
			System.out.println();
		}
	}
	static void debug(Object...os) {
		System.out.println(Arrays.deepToString(os));
	}
	public static void main(String[] args) throws FileNotFoundException {
		in = _READ_FROM_FILE  ? new Scanner(new File("in.in")) : new Scanner(System.in);
		core();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {

    void solve() throws IOException {
        int k = nextInt();
        for ( int i = 1; i < k; i++ ) {
            for ( int j = 1; j < k; j++ ) {
                out.print(Integer.toString(i*j,k) + " ");
            }
            out.println();
        }
    }

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer st;

    Main() throws IOException {
        Locale.setDefault(Locale.US);
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        eat("");
        solve();
        in.close();
        out.close();
    }

    private void eat(String str) {
        st = new StringTokenizer(str);
    }

    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null) {
                return null;
            }
            eat(line);
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}

import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;}
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;}
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
    }

    ///////////////////////////////////////////////////////////////////////////////////////////
    //    RRRRRRRRR            AAA             HHH     HHH     IIIIIIIIIIIII   LLL           //
    //    RR    RRR           AAAAA            HHH     HHH      IIIIIIIIIII    LLL           //
    //    RR   RRR           AAAAAAA           HHH     HHH          III        LLL           //
    //    RR  RRR           AAA   AAA          HHHHHHHHHHH          III        LLL           //
    //    RRRRRR           AAA     AAA         HHHHHHHHHHH          III        LLL           //
    //    RR  RRR         AAAAAAAAAAAAA        HHH     HHH          III        LLL           //
    //    RR    RRR      AAA         AAA       HHH     HHH      IIIIIIIIIII    LLLLLLLLLLLL  //
    //    RR     RRR    AAA           AAA      HHH     HHH     IIIIIIIIIIIII   LLLLLLLLLLLL  //
    ///////////////////////////////////////////////////////////////////////////////////////////
    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int n=sc.i();

        for(int i=1;i<n;i++)
        {
            for(int j=1;j<n;j++)
            {
                int val=i*j;
                StringBuilder s=new StringBuilder("");
                while(val!=0)
                {
                    s=s.append(val%n);
                    val/=n;
                }
                out.print(s.reverse()+" ");
            }
            out.println();

        }
        out.flush();
    }
}

import java.util.*;
public class multtable{
     public static void main(String[] args) {
        Scanner br = new Scanner(System.in);
        int n = br.nextInt();
        String[][] table = new String[n-1][n-1];
        for(int i = 1;i<n;i++){
            for(int j = 1;j<n;j++){
                table[i-1][j-1] = Integer.toString(i*j, n);
            }
        }
        for(int i = 0;i<n-1;i++){
            for(int j = 0;j<n-1;j++){
                System.out.print(table[i][j]+" ");
            }
            System.out.println();
        }
    }
}

import java.io.*;
import java.util.*;
public class j
{
public static void main(String a[])throws IOException
{
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
int k=0,t=0,j=0,p=0,m=0,i=0;
m=Integer.parseInt(b.readLine());
for(j=1;j<m;j++)
{
for(i=1;i<m;i++)
{
p=i*j;
while(p/m!=0)
{
k+=(p%m)*((int)Math.pow(10,t));
p=p/m;
t++;
}
k+=p*((int)Math.pow(10,t));
t=0;
System.out.print(k+" ");
k=0;
}
System.out.print("\n");
}
}
}

/**
 * Created by ChaiChai on 2/1/17.
 */
import java.util.Scanner;
public class Driver {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int radix = in.nextInt();
        String[][]table = new String[radix-1][radix-1];
        for(int row = 0; row<radix-1;row++){
            for(int col = 0; col<radix-1;col++){
                table[row][col]=Integer.toString((row+1)*(col+1), radix);

            }
        }
        for(String[] row:table){
            String ans ="";
            for(String cell: row){
                if(Integer.parseInt(cell)>=10){
                    ans += " " + cell;
                }
                else
                    ans+=" " + cell;
            }
            System.out.println(ans.trim());
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static String toBase(int x, int base) {
        String ans = "";
        int power = 1;
        while (x > 0) {
            ans = (x % base) + ans;
            x /= base;
        }
        return ans;
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);

        int k = in.nextInt();

        for (int i = 1; i < k; ++i) {
            for (int j = 1; j < k; ++j) {
                if (j > 1)
                    System.out.print(" ");
                System.out.print(toBase(i * j, k));
            }
            System.out.println();
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens())
                    tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return tokenizer.nextToken();
        }

        public String nextLine() {
            String line = null;
            try {
                tokenizer = null;
                line =  reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

import java.util.Scanner;

public class H {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=1;i<n;i++){
            for(int j=1;j<n;j++){
                int tmp=i*j;
                System.out.print(Integer.toString(tmp, n)+" ");
            }
            System.out.println();
        }
    }
}

import java.util.*;
// scanner.nextInt();
public class Solution {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

                int n = scanner.nextInt();

                int[][] array = new int[n-2][n-2];

                for(int i = 0; i < array.length; ++i)
                {
                    for(int j = 0; j < array.length; ++j)
                    {
                        array[i][j] = (i+2)*(j+2);
                    }
                }

                String res = "1";
                for(int i = 1; i < n-1; ++i)
                {
                    res += " " + (i+1);
                }
                System.out.println(res);

                if(n > 2)
                {
                    for(int i = 0; i < n-2; ++i)
                    {
                    res = String.valueOf(i+2);
                    for(int j = 0; j < array[i].length; ++j) res += " " + Integer.toString(array[i][j],n);
                        System.out.println(res);
                    }
                }
                /*

                for(int i = 0; i < n; ++i)
                    {
                        array[i] = scanner.nextInt();
                    }
                 */
                //String[] arr = {"aa","bb","c", "d","ee", "ff" , "gg" , "hh", "ii" , "jj" , "k" , "l", "m", "n", "o", "p", "q" , "r", "s", "t", "u" , "v", "w" ,"x", "y", "z"};

    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class H_SchoolTeamContest_1 {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        for(int i = 1; i < n; i++){
            for(int j = 1; j < n;j++){
                out.print(convert(i*j, n) + " ");
            }
            out.println();
        }
        out.close();
    }
    public static int convert(int v, int base){
        int result = 0;
        int start = 1;
        while(v > 0){
            result += (v % base)*start;
            v /= base;
            start *=10;
        }
        return result;
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.util.Scanner;

public class CodeForces {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int size = scanner.nextInt();
        scanner.close();

        for (int i = 1; i < size; i++) {
            for (int j = 1; j < size; j++) {
                int num = i * j;
                StringBuilder number = new StringBuilder();
                while (num != 0) {
                    int remainder = num % size;
                    num /= size;
                    number.append(String.valueOf(remainder));
                }

                System.out.print(number.reverse());
                System.out.print(" ");
            }
            System.out.print("\n");
        }
    }
}

import java.lang.*;
import java.io.*;
import java.util.*;

public class Multiplication  {

	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {

	public void solve(InputReader in, PrintWriter out) {
		int r = in.nextInt(), x;
		int i, j, k;
		String s;

		for (i=1; i<r; ++i) {
			for (j=1,x=i; j<r; ++j,x+=i) {
				s = f(x, r);
				out.print(s + " ");
			}
			out.println();
		}
	}

	String f(int x, int r) {
		StringBuilder sb = new StringBuilder();

		while (x > 0) {
			sb.append((char) (x%r+'0'));
			x /= r;
		}

		return sb.reverse().toString();
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}

	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}
}

import java.util.*;

public class Main {

public static void main(String... args) {

Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i=1; i<n; i++){
  for (int j=1; j<n; j++){
    System.out.print(Integer.toString(i*j,n)+" ");
}
System.out.println();
}

}
}

import java.util.*;
public class H39 {
public static void main(String[] args)
{
	Scanner input = new Scanner(System.in);
	int b = input.nextInt();
	for(int i = 1; i<b; i++)
	{
		for(int j = 1; j<b; j++)
		{
			//cb(i*j, b);
			System.out.print(cb(i*j, b)+" ");
		}
		System.out.println();
	}
}
static int cb(int x, int b)
{
	int res = 0;
	int pow = 1;
	while(x > 0)
	{
		//System.out.println(x+" "+res+" "+pow);
		res += pow * (x%b);
		pow *= 10;
		x /= b;
	}
	return res;
}
}

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");

    void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        int n = nextInt();
        for (int i = 1; i < n; i++) {
            for (int j = 1; j < n; j++) {
                if (j > 1) out.print(' ');
                out.print(Integer.toString(i * j, n));
            }
            out.println();
        }

        out.close();
    }

    /***************************************************************
     * Input
     **************************************************************/
    String nextToken() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
}

import java.util.*;
import java.io.*;
import java.math.*;

public class MultiplicationTable {
    private void solve() throws IOException {
        int k = nextInt();
        String[][] a = new String[k - 1][k - 1];

        for (int i = 0; i < k - 1; i++)
            a[0][i] = String.valueOf(i + 1);
        for (int i = 0; i < k - 1; i++)
            a[i][0] = String.valueOf(i + 1);

        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[0].length; j++) {
                if (i == 0 || j == 0)
                    continue;
                a[i][j] = Integer.toString(new Integer(a[i][0]) * new Integer(a[0][j]), k);
            }
        }

        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[0].length; j++) {
                System.out.print(a[i][j]);
                if (j < a[0].length - 1)
                    System.out.print(" ");
            }
            System.out.println();
        }

    }

    public static void main(String[] args) {
        new MultiplicationTable().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = nextInt();
        }
        return res;
    }

    long[] readLongArray(int size) throws IOException {
        long[] res = new long[size];
        for (int i = 0; i < size; i++) {
            res[i] = nextLong();
        }
        return res;
    }

    double[] readDoubleArray(int size) throws IOException {
        double[] res = new double[size];
        for (int i = 0; i < size; i++) {
            res[i] = nextDouble();
        }
        return res;
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int base = s.nextInt();
        for (int i = 1; i < base; i++) {
            for (int j = 1; j < base; j++) {
                System.out.print(String.format("%s ", Integer.toString(i*j, base)));
            }
            System.out.println();
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class MultiplicationTable {

	public static int conv(int num, int base) {
		String ans = "";
		while (num != 0) {
			ans = (num % base) + ans;
			num /= base;
		}
		return Integer.parseInt(ans);
	}

	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		int k = Integer.parseInt(bf.readLine());
		int[][] ans = new int[k - 1][k - 1];
		for (int i = 0; i < k - 1; i++) {
			ans[0][i] = (i + 1);
			ans[i][0] = (i + 1);
		}
		for (int i = 1; i < k - 1; i++) {
			for (int j = 1; j < k - 1; j++) {
				int tmp = ans[0][j] * ans[i][0];
				ans[i][j] = conv(tmp, k);
			}
		}

		for (int i = 0; i < k - 1; i++) {
			for (int j = 0; j < k - 1; j++) {
				System.out.print(ans[i][j]+" ");
			}
			System.out.println();
		}
	}
}

import java.util.Scanner;

/**
 * @author igor_kz
 */
public class H39 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 1 ; i < n ; i++) {
            for (int j = 1 ; j < n ; j++) {
                int c = i * j;
                Print(c , n);
            }
            System.out.println();
        }
    }

    public static void Print(int c, int n) {
        int[] a = new int[100];
        int cnt = 0;
        while (c > 0) {
            a[cnt++] = c % n;
            c /= n;
        }
        for (int i = cnt - 1 ; i >= 0 ; i--) System.out.print(a[i]);
        System.out.print(" ");
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class cdf39h
{
	static void merge(int arr[], int l, int m, int r)
    {
        int n1 = m - l + 1;
        int n2 = r - m;
        int L[] = new int [n1];
        int R[] = new int [n2];
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];
        int i = 0, j = 0;
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }
    static void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            int m = (l+r)/2;
            sort(arr, l, m);
            sort(arr , m+1, r);
            merge(arr, l, m, r);
        }
    }
    public static int lowerBound(int[] array, int length, int value)
	{
        int low = 0;
        int high = length;
        while (low < high)
        {
            final int mid = (low + high) / 2;
            //checks if the value is less than middle element of the array
            if (value <= array[mid])
            {
                high = mid;
            }
            else
            {
                low = mid + 1;
            }
        }
        return low;
    }
	public static int upperBound(int[] array, int length, int value)
	{
        int low = 0;
        int high = length;
        while (low < high) {
            final int mid = (low + high) / 2;
            if (value >= array[mid]) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return low;
    }
    static int gcd(int a, int b)
    {
      if (b == 0)
        return a;
      return gcd(b, a % b);
    }
    static long power(long n,long m)
    {
    	if(m==0)
    		return 1;
    	long ans=1;
    	while(m>0)
    	{
    		ans=ans*n;
    		m--;
    	}
    	return ans;
    }
    static int BinarySearch(int arr[], int x)
    {
        int l = 0, r = arr.length - 1;
        while (l <= r) {
            int m = l + (r - l) / 2;
            if (arr[m] == x)
                return m;
            if (arr[m] < x)
                l = m + 1;
            else
                r = m - 1;
        }
        return -1;
    }
    static String pri(int n,int base)
    {
    	String ans="";
    	while(n>0)
    	{
    		ans=(n%base)+ans;
    		n/=base;
    	}
    	return ans;
    }
	public static void main(String args[])throws Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;//Integer.parseInt(br.readLine());
	    for(int i=1;i<=t;i++)
	    {
	        int n=Integer.parseInt(br.readLine());
	        for(int j=1;j<n;j++)
	        {
	        	for(int k=1;k<n;k++)
	        	System.out.print(pri(j*k,n)+" ");
	        	System.out.println();
	        }
	        System.out.println();
	    }
	}
}

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
		Scanner in;
		PrintWriter pw;

		public void run () throws Exception {
            in = new Scanner(System.in);
            pw = new PrintWriter(System.out);

            int n = in.nextInt();
            for(int i=1;i<n;i++){
            	for(int j=1;j<n;j++){
            		if(j>1) pw.print(" ");
            		int val = i * j;
            		if(val>=n) pw.print(val/n);
            		pw.print(val%n);
            	}
            	pw.println();
            }

            pw.close();
        }
        public static void main(String[] args) throws Exception {
                new Main ().run();
        }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;

public class A {
	private static StreamTokenizer in;
	private static PrintWriter out;
	static {
		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(
				System.in)));
		out = new PrintWriter(System.out);
	}

	private static int nextInt() throws Exception {
		in.nextToken();
		return (int) in.nval;
	}

	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;
	}

	public static void main(String[] args) throws Exception {
		int n = nextInt();
		for (int i=1; i<n; i++) {
			for (int j=1; j<n; j++) {
				out.print(Integer.toString(i*j, n) + " ");
			}
			out.println();
		}
		out.flush();

	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CodeE
{
	static class Scanner
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String nextLine()
		{
			try
			{
				return br.readLine();
			}
			catch(Exception e)
			{
				throw(new RuntimeException());
			}
		}

		public String next()
		{
			while(!st.hasMoreTokens())
			{
				String l = nextLine();
				if(l == null)
					return null;
				st = new StringTokenizer(l);
			}
			return st.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong()
		{
			return Long.parseLong(next());
		}

		public double nextDouble()
		{
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n)
		{
			int[] res = new int[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextInt();
			return res;
		}

		public long[] nextLongArray(int n)
		{
			long[] res = new long[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}

		public double[] nextDoubleArray(int n)
		{
			double[] res = new double[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}
		public void sortIntArray(int[] array)
		{
			Integer[] vals = new Integer[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortLongArray(long[] array)
		{
			Long[] vals = new Long[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortDoubleArray(double[] array)
		{
			Double[] vals = new Double[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public String[] nextStringArray(int n)
		{
			String[] vals = new String[n];
			for(int i = 0; i < n; i++)
				vals[i] = next();
			return vals;
		}

		Integer nextInteger()
		{
			String s = next();
			if(s == null)
				return null;
			return Integer.parseInt(s);
		}

		int[][] nextIntMatrix(int n, int m)
		{
			int[][] ans = new int[n][];
			for(int i = 0; i < n; i++)
				ans[i] = nextIntArray(m);
			return ans;
		}
	}

	public static void main(String[] args)
	{
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		for(int i = 1; i < n; i++)
			System.out.print((i == 1 ? "" : " ") + i);
		System.out.println();
		for(int i = 2; i < n; i++)
		{
			for(int j = 1; j < n; j++)
				System.out.print((j == 1 ? "" : " ") + (Integer.toString(i * j, n)));
			System.out.println();
		}
	}

}

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();

        for (int i = 1; i < n; i++) {
            for (int j = 1; j < n; j++) {
                Num a = new Num(n, 0, i);
                Num b = new Num(n, 0, j);

                out.print(a.mul(b));
                out.print(" ");
            }
            out.println();
        }

        out.flush();
    }

    private static class Num {

        int osn;
        int first;
        int second;

        public Num(int o, int f, int s) {
            osn = o;
            first = f;
            second = s;
        }

        public String mul(Num a) {
            Integer ansSecond = second * a.second;
            Integer ansFirst = ansSecond / osn;
            ansSecond %= osn;
            String ans;
            if (ansFirst == 0) {
                ans = ansSecond.toString();
            } else {
                ans = ansFirst.toString() + ansSecond.toString();
            }
            return ans;
        }
    }
}

import java.util.Scanner;

/**
 * Created on 2/1/17 at 8:43 AM by Christopher Skalnik
 * for Data Structures under Ryan Ritz, Park Tudor
 * Project: SchoolContest; Module: H-MultiplicationTable; File: Driver
 * Made with: IntelliJ IDEA
 * Copyright (C) 2017 Christopher Skalnik
 * Code Sources:
 * References:
 */
public class Driver {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int radix = s.nextInt();
        int[][] table = new int[radix - 1][radix - 1];
        for (int r = 0; r < table.length; r ++) {
            for (int c = 0; c < table.length; c ++) {
                table[r][c] = (r + 1) * (c + 1);
            }
        }
        for (int[] row : table) {
            String toPrint = "";
            for (int n : row)
                toPrint += Integer.toString(n, radix) + " ";
            System.out.println(toPrint.substring(0, toPrint.length() - 1));
        }
    }
}

import java.io.IOException;
import java.util.Scanner;

public class Solution {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);

        int k = in.nextInt();

        for (int i = 1; i < k; i++) {
            for (int j = 1; j < k; j++) {
                System.out.printf("%s ", Integer.toString(i * j, k));
            }

            System.out.println();
        }
    }
}

import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author madi
 */
public class Round39H {
    public static void main(String[] args) {
        int k = new Scanner(System.in).nextInt();
        for (int i = 1; i < k; i++) {
            for (int j = 1; j < k; j++) {
                System.out.print(convert(i * j, k) + " ");
            }
            System.out.println();
        }
    }

    private static String convert(int a, int k) {
        String res = "";
        while(a > 0) {
            res = a % k + res;
            a = a / k;
        }
        return res;
    }
}

public class H {
	public static void main(String[] args) {
		int n = new java.util.Scanner(System.in).nextInt();
		for (int i = 1; i < n; ++i) {
			for (int j = 1; j < n; ++j) {
				System.out.print(Integer.toString(i * j, n) + " ");
			}
			System.out.println();
		}
	}
}

import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int base = s.nextInt();
        for (int i = 1; i < base; i++) {
            for (int j = 1; j < base; j++) {
                System.out.print(String.format("%s ", Integer.toString(i*j, base)));
            }
            System.out.println();
        }
    }
}

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author quan.vuhong
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i < n; i++) {
            for (int j = 1; j < n; j++) {
                System.out.print(Integer.toString(i*j, n)+" ");
            }
            System.out.println("");
        }
    }

}

import java.util.Scanner;

public class h39 {
public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int rdx = in.nextInt();
	for (int i = 1; i < rdx; i++) {
		for (int j = 1; j < rdx; j++) {
			System.out.printf("%s ", Integer.toString(i*j, rdx));
		}
		System.out.println();
	}
}
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {

	public static void main( String[] args ) throws FileNotFoundException {
    	new CodeForces_39H().doit();
    }
}
class CodeForces_39H {
	InputReader ir;
	Scanner sc;
	PrintStream ps;
	public void doit() throws FileNotFoundException {
		ir = new InputReader( System.in );
		//Scan sn = new Scan( System.in );
		//Scan sn = new Scan( new FileInputStream("1006.in") );
		//sc = new Scanner( System.in );
		ps = System.out;
		//ps = new PrintStream(new FileOutputStream(new File("test")));
		int n = ir.nextInt();
		for ( int i = 1; i < n; i++ ) {
			ps.print( i );
			for ( int j = 2; j < n; j++ ) {
				ps.printf( "%3d", Integer.parseInt( Integer.toString( i*j, n) ) );
			}
			ps.println();
		}
	}
}
class InputReader {
	private BufferedReader reader;
	private StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}
	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong( next() );
	}
	public double nextDouble() {
		return Double.parseDouble( next() );
	}
}
class Scan {
	InputStream inp;
	public Scan(InputStream in) {
		inp = in;
	}
	public String next() {
		StringBuffer res = new StringBuffer();
		try {
			int t = inp.read();
			while ( (t < 'a' || t > 'z') && (t < 'A' || t > 'Z') && ( t < '1' || t < '9') ) t = inp.read();
			while ( ('a' <= t && t <= 'z') || ('A' <= t && t <= 'Z') || ('1' <= t && t <= '9') ) {
				res.append( ((char)t) );
				t = inp.read();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return res.toString();
	}
	public int nextInt() {
		boolean isN = false;
		int res = 0;
		int t;
		try {
			t = inp.read();
			if (t == -1) return -1;
			while (t != -1 && t != '-' && (t > '9' || t < '0')) t = inp.read();
			if ( t == '-' ) {
				isN = true;
				t = inp.read();
			}
			while (t != -1 && t >= '0' && t <= '9') {
				res = res * 10 + (t - '0');
				t = inp.read();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		if ( isN ) res = -res;
		return res;
	}
	public double nextDouble() {
		double res = 0, Dec = 0.1;
		boolean isN = false, isD = false;
    	int t;
    	try {
    		t = inp.read();
			if ( t == -1 ) return -1;
			while ( t != '-' && t != '.' && (t < '0' || t > '9') ) t = inp.read();
			if ( t == '-' ) {
				isN = true;
				res = 0;
			} else if ( t == '.' ) {
				isD = true;
				res = 0;
			} else res = (double) t - '0';
			if ( !isD ) {
				t = inp.read();
				while ( t >= '0' && t <= '9' ) {
					res = res * 10 + (t - '0');
					t = inp.read();
				}
			}
			if ( t != '.' ) {
				if ( isN ) res = -res;
				return res;
			} else {
				t = inp.read();
				while ( t >= '0' && t <= '9' ) {
					res += Dec * (t - '0');
					Dec *= 0.1;
					t= inp.read();
				}
			}
			if ( isN ) res = -res;
		} catch (IOException e) {
			e.printStackTrace();
		}
    	return res;
    }
}

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.io.*;

public class Xtend {

public static void main(String[] args)throws IOException{
BufferedReader x=new BufferedReader(new InputStreamReader(System.in));
int a=Integer.parseInt(x.readLine());
String[][]array=new String[a-1][a-1];
for(int i=1;i<=a-1;i++){
	for(int j=1;j<=a-1;j++){
		array[i-1][j-1]=Integer.toString(i*j,a);
	}
}
for(int r=0;r<a-1;r++){
	for(int s=0;s<a-1;s++){
		System.out.print(array[r][s]+" ");
	}
	System.out.println();
}
}

}

import java.util.Scanner;
public class multiplicationTable {
    public static void main(String[] args) {
        Integer.toString(3, 4); //to convert bases
        Scanner in = new Scanner(System.in);
        int tableSize = in.nextInt();
        in.nextLine();

        for (int i = 1; i < tableSize; i++) {
            for (int j = 1; j < tableSize; j++) {
                System.out.print(Integer.toString(i*j, tableSize) + " ");
            }
            System.out.println(" ");
        }

    }
}

import java.io.*;
import java.util.*;

public class Solution {

    StreamTokenizer in;
    PrintWriter out;

    public static void main(String[] args) throws Exception {
        new Solution().run();
    }

    int nextInt() throws Exception {
        in.nextToken();
        return (int) in.nval;
    }

    public void run() throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        int n =nextInt();
        for (int i=1; i<n; ++i) {
            for (int j=1; j<n; ++j)
                out.print(Integer.toString(i*j,n)+" ");
            out.println();
        }
        out.flush();
    }

}

import java.util.*;
public class H39 {
public static void main(String[] args)
{
	Scanner input = new Scanner(System.in);
	int b = input.nextInt();
	for(int i = 1; i<b; i++)
	{
		for(int j = 1; j<b; j++)
		{
			//cb(i*j, b);
			System.out.print(cb(i*j, b)+" ");
		}
		System.out.println();
	}
}
static int cb(int x, int b)
{
	int res = 0;
	int pow = 1;
	while(x > 0)
	{
		//System.out.println(x+" "+res+" "+pow);
		res += pow * (x%b);
		pow *= 10;
		x /= b;
	}
	return res;
}
}

import java.util.*;

public class Main {

  public static void main(String args[]) {
    (new Main()).solve();
  }

  void solve() {

    Scanner cin = new Scanner(System.in);

    while( cin.hasNextInt() ) {

      int k = cin.nextInt();

      for(int i=1; i<k; ++i) {
        for(int j=1; j<k; ++j) {
          System.out.print(Integer.toString(i * j, k) + " ");
        }
        System.out.println();
      }

    }

  }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Yury Bandarchuk
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();
            for (int i = 1; i < k; i++) {
                for (int j = 1; j < k; j++) {
                    out.print(get(i * j, k));
                    if (j == k - 1) {
                        out.println("");
                    } else {
                        out.print(" ");
                    }
                }
            }
        }

        String get(int val, int base) {
            String result = "";
            while (val > 0) {
                int digit = (val % base);
                result = result + (char) (digit + 48);
                val /= base;
            }
            return result;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.util.Scanner;
public class MultiplicationTable {

    public static void main(String[] args)
    {
       Scanner scan = new Scanner(System.in);
       int x = scan.nextInt();

       for (int i=1; i<x ; i++)
       {
           for (int j=1; j<x;j++)
           {
               System.out.print((i*j/x)*10 + (i*j%x));
           }
           System.out.println("  ");
       }
    }

}

import java.util.*;
public class susbus{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int k =sc.nextInt();
      int [][] result = new int[k-1][k-1];
      for (int i=0;i<k-1;i++){
         for (int j=0;j<k-1;j++){
          result[i][j]=(i+1)*(j+1);

         }
      }
      for (int i=0;i<k-1;i++){
         for (int j=0;j<k-1;j++){
            result[i][j] = convertBase(result[i][j],k);
            System.out.println(result[i][j]);
         }
      }

   }
   public static int convertBase(int n, int base){
      String nibbas = "";
      while(n>0){
         nibbas+=n%base;
         n=n/base;
      }
      String bibba = "";
      for (int i=0;i<nibbas.length();i++){
         bibba+=nibbas.charAt(nibbas.length()-i-1);
      }
      return Integer.parseInt(bibba);
   }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Multiplication_Table_G {
	public static void main(String[] args)throws Throwable {
		BufferedReader bf = new BufferedReader(new InputStreamReader (System.in));
		PrintWriter pw = new PrintWriter(System.out, true);
		int num=Integer.parseInt(bf.readLine());
		int[][] ans=new int[num-1][num-1];
		for(int i=0;i!=num-1;i++)
		{
			for(int j=0;j!=num-1;j++)
			{
				ans[i][j]=(i+1)*(j+1);
			}
		}
		for(int[] i:ans)
		{
			for(int j:i)
			{
				pw.print(j+" ");
			}
			pw.println();
		}
		pw.close();
	}
}

import java.util.Scanner;
public class multiplicationTable {
    public static void main(String[] args) {
        Integer.toString(3, 4); //to convert bases
        Scanner in = new Scanner(System.in);
        int tableSize = in.nextInt();
        in.nextLine();

        System.out.println(" ");

        for (int i = 1; i < tableSize; i++) {
            for (int j = 1; j < tableSize; j++) {
                System.out.print(Integer.toString(i*j, tableSize) + " ");
            }
            System.out.println(" ");
        }

    }
}

import java.util.Scanner;
public class multiplicationTable {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int tableSize = in.nextInt();
        in.nextLine();
        String[] ans = new String[tableSize];

        for (int i = 1; i < tableSize; i++) {
            for (int j = 1; j < tableSize; j++) {
                ans[i-1] = Integer.toString(i*j, tableSize);
            }
            System.out.println(ans);
        }

    }
}

import java.util.Scanner;
public class driver {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        for(int i = 1; i<n; i++){
            System.out.print(i);
            for(int o = 1; o<n; o++){
                Integer p = i*o;
                String q = Integer.toString(p, n);
                System.out.print(q);
            }
            System.out.println();
        }
    }
}

import java.util.Scanner;

/**
 * Created by max_b on 2/1/2017.
 */
public class driver {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        for(int i = 1; i<n; i++){
            System.out.print(i);
            for(int o = 1; o<n; o++){
                Integer p = i*o;
                String q = Integer.toString(p, n);
                System.out.print(q);
            }
            System.out.println();
        }
    }
}

import java.util.Scanner;

/**
 * Created by max_b on 2/1/2017.
 */
public class driver {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        for(int i = 1; i<n; i++){

            for(int o = 1; o<n; o++){
                Integer p = i*o;
                String q = Integer.toString(p, n);
                System.out.print(q);
            }
            System.out.println();
        }
    }
}

/*
 * Hello! You are trying to hack my solution, are you? =)
 * Don't be afraid of the size, it's just a dump of useful methods like gcd, or n-th Fib number.
 * And I'm just too lazy to create a new .java for every task.
 * And if you were successful to hack my solution, please, send me this test as a message or to Abrackadabraa@gmail.com.
 * It can help me improve my skills and i'd be very grateful for that.
 * Sorry for time you spent reading this message. =)
 * Good luck, unknown rival. =)
 * */

import java.io.*;
import java.math.*;
import java.util.*;

public class Abra {
    // double d = 2.2250738585072012e-308;
    void solve() throws IOException {
        int n = nextInt();
        for (int i = 1; i < n; i++) {
            for (int j = 1; j < n; j++) {
                out.print(i * j + " ");
            }
            out.println();
        }
    }

    public static void main(String[] args) throws IOException {
        new Abra().run();
    }

    StreamTokenizer in;
    PrintWriter out;
    boolean oj;
    BufferedReader br;

    void init() throws IOException {
        oj = System.getProperty("ONLINE_JUDGE") != null;
        Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
        Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
        br = new BufferedReader(reader);
        in = new StreamTokenizer(br);
        out = new PrintWriter(writer);
    }

    long beginTime;

    void run() throws IOException {
        beginTime = System.currentTimeMillis();
        long beginMem = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
        init();
        solve();
        long endMem = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
        long endTime = System.currentTimeMillis();
        if (!oj) {
            System.out.println("Memory used = " + (endMem - beginMem));
            System.out.println("Total memory = " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
            System.out.println("Running time = " + (endTime - beginTime));
        }
        out.flush();
    }

    int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }

    double nextDouble() throws IOException {
        in.nextToken();
        return in.nval;
    }

    myLib lib = new myLib();

    void time() {
        System.out.print("It's ");
        System.out.println(System.currentTimeMillis() - beginTime);
    }

    static class myLib {
        long fact(long x) {
            long a = 1;
            for (long i = 2; i <= x; i++) {
                a *= i;
            }
            return a;
        }

        long digitSum(String x) {
            long a = 0;
            for (int i = 0; i < x.length(); i++) {
                a += x.charAt(i) - '0';
            }
            return a;
        }

        long digitSum(long x) {
            long a = 0;
            while (x > 0) {
                a += x % 10;
                x /= 10;
            }
            return a;
        }

        long digitMul(long x) {
            long a = 1;
            while (x > 0) {
                a *= x % 10;
                x /= 10;
            }
            return a;
        }

        int digitCubesSum(int x) {
            int a = 0;
            while (x > 0) {
                a += (x % 10) * (x % 10) * (x % 10);
                x /= 10;
            }
            return a;
        }

        double pif(double ax, double ay, double bx, double by) {
            return Math.sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
        }

        double pif3D(double ax, double ay, double az, double bx, double by, double bz) {
            return Math.sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by) + (az - bz) * (az - bz));
        }

        double pif3D(double[] a, double[] b) {
            return Math.sqrt((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]) + (a[2] - b[2]) * (a[2] - b[2]));
        }

        long gcd(long a, long b) {
            if (a == 0 || b == 0) return 1;
            if (a < b) {
                long c = b;
                b = a;
                a = c;
            }
            while (a % b != 0) {
                a = a % b;
                if (a < b) {
                    long c = b;
                    b = a;
                    a = c;
                }
            }
            return b;
        }

        int gcd(int a, int b) {
            if (a == 0 || b == 0) return 1;
            if (a < b) {
                int c = b;
                b = a;
                a = c;
            }
            while (a % b != 0) {
                a = a % b;
                if (a < b) {
                    int c = b;
                    b = a;
                    a = c;
                }
            }
            return b;
        }

        long lcm(long a, long b) {
            return a * b / gcd(a, b);
        }

        int lcm(int a, int b) {
            return a * b / gcd(a, b);
        }

        int countOccurences(String x, String y) {
            int a = 0, i = 0;
            while (true) {
                i = y.indexOf(x);
                if (i == -1) break;
                a++;
                y = y.substring(i + 1);
            }
            return a;
        }

        int[] findPrimes(int x) {
            boolean[] forErato = new boolean[x - 1];
            List<Integer> t = new Vector<Integer>();
            int l = 0, j = 0;
            for (int i = 2; i < x; i++) {
                if (forErato[i - 2]) continue;
                t.add(i);
                l++;
                j = i * 2;
                while (j < x) {
                    forErato[j - 2] = true;
                    j += i;
                }
            }
            int[] primes = new int[l];
            Iterator<Integer> iterator = t.iterator();
            for (int i = 0; iterator.hasNext(); i++) {
                primes[i] = iterator.next().intValue();
            }
            return primes;
        }

        int rev(int x) {
            int a = 0;
            while (x > 0) {
                a = a * 10 + x % 10;
                x /= 10;
            }
            return a;
        }

        class myDate {
            int d, m, y;

            int[] ml = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

            public myDate(int da, int ma, int ya) {
                d = da;
                m = ma;
                y = ya;
                if ((ma > 12 || ma < 1 || da > ml[ma - 1] || da < 1) && !(d == 29 && m == 2 && y % 4 == 0)) {
                    d = 1;
                    m = 1;
                    y = 9999999;
                }
            }

            void incYear(int x) {
                for (int i = 0; i < x; i++) {
                    y++;
                    if (m == 2 && d == 29) {
                        m = 3;
                        d = 1;
                        return;
                    }
                    if (m == 3 && d == 1) {
                        if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) {
                            m = 2;
                            d = 29;
                        }
                        return;
                    }
                }
            }

            boolean less(myDate x) {
                if (y < x.y) return true;
                if (y > x.y) return false;
                if (m < x.m) return true;
                if (m > x.m) return false;
                if (d < x.d) return true;
                if (d > x.d) return false;
                return true;
            }

            void inc() {
                if ((d == 31) && (m == 12)) {
                    y++;
                    d = 1;
                    m = 1;
                } else {
                    if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) {
                        ml[1] = 29;
                    }
                    if (d == ml[m - 1]) {
                        m++;
                        d = 1;
                    } else
                        d++;
                }
            }
        }

        int partition(int n, int l, int m) {// n - sum, l - length, m - every
                                            // part
            // <= m
            if (n < l) return 0;
            if (n < l + 2) return 1;
            if (l == 1) return 1;
            int c = 0;
            for (int i = Math.min(n - l + 1, m); i >= (n + l - 1) / l; i--) {
                c += partition(n - i, l - 1, i);
            }
            return c;
        }

        int rifmQuality(String a, String b) {
            if (a.length() > b.length()) {
                String c = a;
                a = b;
                b = c;
            }
            int c = 0, d = b.length() - a.length();
            for (int i = a.length() - 1; i >= 0; i--) {
                if (a.charAt(i) == b.charAt(i + d)) c++;
                else
                    break;
            }
            return c;
        }

        String numSym = "0123456789ABCDEF";

        String ZFromXToYNotation(int x, int y, String z) {
            if (z.equals("0")) return "0";
            String a = "";
            // long q = 0, t = 1;
            BigInteger q = BigInteger.ZERO, t = BigInteger.ONE;
            for (int i = z.length() - 1; i >= 0; i--) {
                q = q.add(t.multiply(BigInteger.valueOf(z.charAt(i) - 48)));
                t = t.multiply(BigInteger.valueOf(x));
            }
            while (q.compareTo(BigInteger.ZERO) == 1) {
                a = numSym.charAt((int) (q.mod(BigInteger.valueOf(y)).intValue())) + a;
                q = q.divide(BigInteger.valueOf(y));
            }
            return a;
        }

        double angleFromXY(int x, int y) {
            if ((x == 0) && (y > 0)) return Math.PI / 2;
            if ((x == 0) && (y < 0)) return -Math.PI / 2;
            if ((y == 0) && (x > 0)) return 0;
            if ((y == 0) && (x < 0)) return Math.PI;
            if (x > 0) return Math.atan((double) y / x);
            else {
                if (y > 0) return Math.atan((double) y / x) + Math.PI;
                else
                    return Math.atan((double) y / x) - Math.PI;
            }
        }

        static boolean isNumber(String x) {
            try {
                Integer.parseInt(x);
            } catch (NumberFormatException ex) {
                return false;
            }
            return true;
        }

        static boolean stringContainsOf(String x, String c) {
            for (int i = 0; i < x.length(); i++) {
                if (c.indexOf(x.charAt(i)) == -1) return false;
            }
            return true;
        }

        long pow(long a, long n) { // b > 0
            if (n == 0) return 1;
            long k = n, b = 1, c = a;
            while (k != 0) {
                if (k % 2 == 0) {
                    k /= 2;
                    c *= c;
                } else {
                    k--;
                    b *= c;
                }
            }
            return b;
        }

        int pow(int a, int n) { // b > 0
            if (n == 0) return 1;
            int k = n, b = 1, c = a;
            while (k != 0) {
                if (k % 2 == 0) {
                    k /= 2;
                    c *= c;
                } else {
                    k--;
                    b *= c;
                }
            }
            return b;
        }

        double pow(double a, int n) { // b > 0
            if (n == 0) return 1;
            double k = n, b = 1, c = a;
            while (k != 0) {
                if (k % 2 == 0) {
                    k /= 2;
                    c *= c;
                } else {
                    k--;
                    b *= c;
                }
            }
            return b;
        }

        double log2(double x) {
            return Math.log(x) / Math.log(2);
        }

        int lpd(int[] primes, int x) {// least prime divisor
            int i;
            for (i = 0; primes[i] <= x / 2; i++) {
                if (x % primes[i] == 0) {
                    return primes[i];
                }
            }
            ;
            return x;
        }

        int np(int[] primes, int x) {// number of prime number
            for (int i = 0; true; i++) {
                if (primes[i] == x) return i;
            }
        }

        int[] dijkstra(int[][] map, int n, int s) {
            int[] p = new int[n];
            boolean[] b = new boolean[n];
            Arrays.fill(p, Integer.MAX_VALUE);
            p[s] = 0;
            b[s] = true;
            for (int i = 0; i < n; i++) {
                if (i != s) p[i] = map[s][i];
            }
            while (true) {
                int m = Integer.MAX_VALUE, mi = -1;
                for (int i = 0; i < n; i++) {
                    if (!b[i] && (p[i] < m)) {
                        mi = i;
                        m = p[i];
                    }
                }
                if (mi == -1) break;
                b[mi] = true;
                for (int i = 0; i < n; i++)
                    if (p[mi] + map[mi][i] < p[i]) p[i] = p[mi] + map[mi][i];
            }
            return p;
        }

        boolean isLatinChar(char x) {
            if (((x >= 'a') && (x <= 'z')) || ((x >= 'A') && (x <= 'Z'))) return true;
            else
                return false;
        }

        boolean isBigLatinChar(char x) {
            if (x >= 'A' && x <= 'Z') return true;
            else
                return false;
        }

        boolean isSmallLatinChar(char x) {
            if (x >= 'a' && x <= 'z') return true;
            else
                return false;
        }

        boolean isDigitChar(char x) {
            if (x >= '0' && x <= '9') return true;
            else
                return false;
        }

        class NotANumberException extends Exception {
            private static final long serialVersionUID = 1L;
            String mistake;

            NotANumberException() {
                mistake = "Unknown.";
            }

            NotANumberException(String message) {
                mistake = message;
            }
        }

        class Real {
            String num = "0";
            long exp = 0;
            boolean pos = true;

            long length() {
                return num.length();
            }

            void check(String x) throws NotANumberException {
                if (!stringContainsOf(x, "0123456789+-.eE")) throw new NotANumberException("Illegal character.");
                long j = 0;
                for (long i = 0; i < x.length(); i++) {
                    if ((x.charAt((int) i) == '-') || (x.charAt((int) i) == '+')) {
                        if (j == 0) j = 1;
                        else
                            if (j == 5) j = 6;
                            else
                                throw new NotANumberException("Unexpected sign.");
                    } else
                        if ("0123456789".indexOf(x.charAt((int) i)) != -1) {
                            if (j == 0) j = 2;
                            else
                                if (j == 1) j = 2;
                                else
                                    if (j == 2)
                                    ;
                                    else
                                        if (j == 3) j = 4;
                                        else
                                            if (j == 4)
                                            ;
                                            else
                                                if (j == 5) j = 6;
                                                else
                                                    if (j == 6)
                                                    ;
                                                    else
                                                        throw new NotANumberException("Unexpected digit.");
                        } else
                            if (x.charAt((int) i) == '.') {
                                if (j == 0) j = 3;
                                else
                                    if (j == 1) j = 3;
                                    else
                                        if (j == 2) j = 3;
                                        else
                                            throw new NotANumberException("Unexpected dot.");
                            } else
                                if ((x.charAt((int) i) == 'e') || (x.charAt((int) i) == 'E')) {
                                    if (j == 2) j = 5;
                                    else
                                        if (j == 4) j = 5;
                                        else
                                            throw new NotANumberException("Unexpected exponent.");
                                } else
                                    throw new NotANumberException("O_o.");
                }
                if ((j == 0) || (j == 1) || (j == 3) || (j == 5)) throw new NotANumberException("Unexpected end.");
            }

            public Real(String x) throws NotANumberException {
                check(x);
                if (x.charAt(0) == '-') pos = false;
                long j = 0;
                String e = "";
                boolean epos = true;
                for (long i = 0; i < x.length(); i++) {
                    if ("0123456789".indexOf(x.charAt((int) i)) != -1) {
                        if (j == 0) num += x.charAt((int) i);
                        if (j == 1) {
                            num += x.charAt((int) i);
                            exp--;
                        }
                        if (j == 2) e += x.charAt((int) i);
                    }
                    if (x.charAt((int) i) == '.') {
                        if (j == 0) j = 1;
                    }
                    if ((x.charAt((int) i) == 'e') || (x.charAt((int) i) == 'E')) {
                        j = 2;
                        if (x.charAt((int) (i + 1)) == '-') epos = false;
                    }
                }
                while ((num.length() > 1) && (num.charAt(0) == '0'))
                    num = num.substring(1);
                while ((num.length() > 1) && (num.charAt(num.length() - 1) == '0')) {
                    num = num.substring(0, num.length() - 1);
                    exp++;
                }
                if (num.equals("0")) {
                    exp = 0;
                    pos = true;
                    return;
                }
                while ((e.length() > 1) && (e.charAt(0) == '0'))
                    e = e.substring(1);
                try {
                    if (e != "") if (epos) exp += Long.parseLong(e);
                    else
                        exp -= Long.parseLong(e);
                } catch (NumberFormatException exc) {
                    if (!epos) {
                        num = "0";
                        exp = 0;
                        pos = true;
                    } else {
                        throw new NotANumberException("Too long exponent");
                    }
                }
            }

            public Real() {
            }

            String toString(long mantissa) {
                String a = "", b = "";
                if (exp >= 0) {
                    a = num;
                    if (!pos) a = '-' + a;
                    for (long i = 0; i < exp; i++)
                        a += '0';
                    for (long i = 0; i < mantissa; i++)
                        b += '0';
                    if (mantissa == 0) return a;
                    else
                        return a + "." + b;
                } else {
                    if (exp + length() <= 0) {
                        a = "0";
                        if (mantissa == 0) {
                            return a;
                        }
                        if (mantissa < -(exp + length() - 1)) {
                            for (long i = 0; i < mantissa; i++)
                                b += '0';
                            return a + "." + b;
                        } else {
                            if (!pos) a = '-' + a;
                            for (long i = 0; i < mantissa; i++)
                                if (i < -(exp + length())) b += '0';
                                else
                                    if (i + exp >= 0) b += '0';
                                    else
                                        b += num.charAt((int) (i + exp + length()));
                            return a + "." + b;
                        }
                    } else {
                        if (!pos) a = "-";
                        for (long i = 0; i < exp + length(); i++)
                            a += num.charAt((int) i);
                        if (mantissa == 0) return a;
                        for (long i = exp + length(); i < exp + length() + mantissa; i++)
                            if (i < length()) b += num.charAt((int) i);
                            else
                                b += '0';
                        return a + "." + b;
                    }
                }
            }
        }

        boolean containsRepeats(int... num) {
            Set<Integer> s = new TreeSet<Integer>();
            for (int d : num)
                if (!s.contains(d)) s.add(d);
                else
                    return true;
            return false;
        }

        int[] rotateDice(int[] a, int n) {
            int[] c = new int[6];
            if (n == 0) {
                c[0] = a[1];
                c[1] = a[5];
                c[2] = a[2];
                c[3] = a[0];
                c[4] = a[4];
                c[5] = a[3];
            }
            if (n == 1) {
                c[0] = a[2];
                c[1] = a[1];
                c[2] = a[5];
                c[3] = a[3];
                c[4] = a[0];
                c[5] = a[4];
            }
            if (n == 2) {
                c[0] = a[3];
                c[1] = a[0];
                c[2] = a[2];
                c[3] = a[5];
                c[4] = a[4];
                c[5] = a[1];
            }
            if (n == 3) {
                c[0] = a[4];
                c[1] = a[1];
                c[2] = a[0];
                c[3] = a[3];
                c[4] = a[5];
                c[5] = a[2];
            }
            if (n == 4) {
                c[0] = a[0];
                c[1] = a[2];
                c[2] = a[3];
                c[3] = a[4];
                c[4] = a[1];
                c[5] = a[5];
            }
            if (n == 5) {
                c[0] = a[0];
                c[1] = a[4];
                c[2] = a[1];
                c[3] = a[2];
                c[4] = a[3];
                c[5] = a[5];
            }
            return c;
        }

        int min(int... a) {
            int c = Integer.MAX_VALUE;
            for (int d : a)
                if (d < c) c = d;
            return c;
        }

        int max(int... a) {
            int c = Integer.MIN_VALUE;
            for (int d : a)
                if (d > c) c = d;
            return c;
        }

        int pos(int x) {
            if (x > 0) return x;
            else
                return 0;
        }

        long pos(long x) {
            if (x > 0) return x;
            else
                return 0;
        }

        double maxD(double... a) {
            double c = Double.MIN_VALUE;
            for (double d : a)
                if (d > c) c = d;
            return c;
        }

        double minD(double... a) {
            double c = Double.MAX_VALUE;
            for (double d : a)
                if (d < c) c = d;
            return c;
        }

        int[] normalizeDice(int[] a) {
            int[] c = a.clone();
            if (c[0] != 0) if (c[1] == 0) c = rotateDice(c, 0);
            else
                if (c[2] == 0) c = rotateDice(c, 1);
                else
                    if (c[3] == 0) c = rotateDice(c, 2);
                    else
                        if (c[4] == 0) c = rotateDice(c, 3);
                        else
                            if (c[5] == 0) c = rotateDice(rotateDice(c, 0), 0);
            while (c[1] != min(c[1], c[2], c[3], c[4]))
                c = rotateDice(c, 4);
            return c;
        }

        boolean sameDice(int[] a, int[] b) {
            for (int i = 0; i < 6; i++)
                if (a[i] != b[i]) return false;
            return true;
        }

        final double goldenRatio = (1 + Math.sqrt(5)) / 2;
        final double aGoldenRatio = (1 - Math.sqrt(5)) / 2;

        long Fib(int n) {
            if (n < 0) if (n % 2 == 0) return -Math.round((pow(goldenRatio, -n) - pow(aGoldenRatio, -n)) / Math.sqrt(5));
            else
                return -Math.round((pow(goldenRatio, -n) - pow(aGoldenRatio, -n)) / Math.sqrt(5));
            return Math.round((pow(goldenRatio, n) - pow(aGoldenRatio, n)) / Math.sqrt(5));
        }

        class japaneeseComparator implements Comparator<String> {
            @Override
            public int compare(String a, String b) {
                int ai = 0, bi = 0;
                boolean m = false, ns = false;
                if (a.charAt(ai) <= '9' && a.charAt(ai) >= '0') {
                    if (b.charAt(bi) <= '9' && b.charAt(bi) >= '0') m = true;
                    else
                        return -1;
                }
                if (b.charAt(bi) <= '9' && b.charAt(bi) >= '0') {
                    if (a.charAt(ai) <= '9' && a.charAt(ai) >= '0') m = true;
                    else
                        return 1;
                }
                a += "!";
                b += "!";
                int na = 0, nb = 0;
                while (true) {
                    if (a.charAt(ai) == '!') {
                        if (b.charAt(bi) == '!') break;
                        return -1;
                    }
                    if (b.charAt(bi) == '!') {
                        return 1;
                    }
                    if (m) {
                        int ab = -1, bb = -1;
                        while (a.charAt(ai) <= '9' && a.charAt(ai) >= '0') {
                            if (ab == -1) ab = ai;
                            ai++;
                        }
                        while (b.charAt(bi) <= '9' && b.charAt(bi) >= '0') {
                            if (bb == -1) bb = bi;
                            bi++;
                        }
                        m = !m;
                        if (ab == -1) {
                            if (bb == -1) continue;
                            else
                                return 1;
                        }
                        if (bb == -1) return -1;
                        while (a.charAt(ab) == '0' && ab + 1 != ai) {
                            ab++;
                            if (!ns) na++;
                        }
                        while (b.charAt(bb) == '0' && bb + 1 != bi) {
                            bb++;
                            if (!ns) nb++;
                        }
                        if (na != nb) ns = true;
                        if (ai - ab < bi - bb) return -1;
                        if (ai - ab > bi - bb) return 1;
                        for (int i = 0; i < ai - ab; i++) {
                            if (a.charAt(ab + i) < b.charAt(bb + i)) return -1;
                            if (a.charAt(ab + i) > b.charAt(bb + i)) return 1;
                        }
                    } else {
                        m = !m;
                        while (true) {
                            if (a.charAt(ai) <= 'z' && a.charAt(ai) >= 'a' && b.charAt(bi) <= 'z' && b.charAt(bi) >= 'a') {
                                if (a.charAt(ai) < b.charAt(bi)) return -1;
                                if (a.charAt(ai) > b.charAt(bi)) return 1;
                                ai++;
                                bi++;
                            } else
                                if (a.charAt(ai) <= 'z' && a.charAt(ai) >= 'a') return 1;
                                else
                                    if (b.charAt(bi) <= 'z' && b.charAt(bi) >= 'a') return -1;
                                    else
                                        break;
                        }
                    }
                }
                if (na < nb) return 1;
                if (na > nb) return -1;
                return 0;
            }
        }

        Random random = new Random();
    }

    void readIntArray(int[] a) throws IOException {
        for (int i = 0; i < a.length; i++)
            a[i] = nextInt();
    }

    String readChars(int l) throws IOException {
        String r = "";
        for (int i = 0; i < l; i++)
            r += (char) br.read();
        return r;
    }

    class myFraction {
        long num = 0, den = 1;

        void reduce() {
            long d = lib.gcd(num, den);
            num /= d;
            den /= d;
        }

        myFraction(long ch, long zn) {
            num = ch;
            den = zn;
            reduce();
        }

        myFraction add(myFraction t) {
            long nd = lib.lcm(den, t.den);
            myFraction r = new myFraction(nd / den * num + nd / t.den * t.num, nd);
            r.reduce();
            return r;
        }

        public String toString() {
            return num + "/" + den;
        }

        int lev(String s1, String s2) {
            int[][] distance = new int[s1.length() + 1][s2.length() + 1];
            for (int i = 0; i <= s1.length(); i++)
                distance[i][0] = i;
            for (int j = 0; j <= s2.length(); j++)
                distance[0][j] = j;
            for (int i = 1; i <= s1.length(); i++)
                for (int j = 1; j <= s2.length(); j++)
                        distance[i][j] = Math.min(Math.min(distance[i - 1][j] + 1, distance[i][j - 1] + 1), distance[i - 1][j - 1] + ((s1.charAt(i - 1) == s2.charAt(j - 1)) ? 0 : 1));
            return distance[s1.length()][s2.length()];
        }
    }

    class myPoint {
        myPoint(int a, int b) {
            x = a;
            y = b;
        }

        int x, y;

        boolean equals(myPoint a) {
            if (x == a.x && y == a.y) return true;
            else
                return false;
        }

        public String toString() {
            return x + ":" + y;
        }
    }
}