import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int[] r = new int[n];
		int[] f = new int[n];
		int[] v = new int[n];
		for(int i=0; i<n; i++)
		{
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		}
		
		String[][]  s = new String[15][20];
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		}
			for(int i=0; i<15; i++)
			{
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		}
		
		
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int[] r = new int[n];
		int[] f = new int[n];
		int[] v = new int[n];
		for(int i=0; i<n; i++)
		{
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		}
		
		String[][]  s = new String[15][20];
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		}
			for(int i=0; i<15; i++)
			{
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		}
		
		
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		}
	}
} Main public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int[] r = new int[n];
		int[] f = new int[n];
		int[] v = new int[n];
		for(int i=0; i<n; i++)
		{
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		}
		
		String[][]  s = new String[15][20];
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		}
			for(int i=0; i<15; i++)
			{
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		}
		
		
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int[] r = new int[n];
		int[] f = new int[n];
		int[] v = new int[n];
		for(int i=0; i<n; i++)
		{
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		}
		
		String[][]  s = new String[15][20];
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		}
			for(int i=0; i<15; i++)
			{
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		}
		
		
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int[] r = new int[n]; r new int[n] n int[] f = new int[n]; f new int[n] n int[] v = new int[n]; v new int[n] n for(int i=0; i<n; i++)
		{
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		} {
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		} int b = scanner.nextInt(); b scanner.nextInt() scanner.nextInt scanner r[i] = scanner.nextInt() r[i] r i scanner.nextInt() scanner.nextInt scanner f[i] = scanner.nextInt() f[i] f i scanner.nextInt() scanner.nextInt scanner v[i] = scanner.nextInt() v[i] v i scanner.nextInt() scanner.nextInt scanner r[i] =  (4*(b-1)  + r[i] - 1) r[i] r i (4*(b-1)  + r[i] - 1) 4*(b-1)  + r[i] 4*(b-1) 4 (b-1) b 1 r[i] r i 1 f[i] = f[i]*2 - 1 f[i] f i f[i]*2 - 1 f[i]*2 f[i] f i 2 1 String[][]  s = new String[15][20]; s new String[15][20] 15 20 for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		} int i=0; int i=0; i 0 i<15 i 15 i++ i++ i {
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		} {
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		} for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			} int j=0; int j=0; j 0 j<20 j 20 j++ j++ j {
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			} {
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			} if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				} i%4 == 3 i%4 i 4 3 {
					s[i][j] = "#";
				} s[i][j] = "#" s[i][j] s[i] s i j "#" if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				} j%2 == 0 j%2 j 2 0 {
					s[i][j] = " ";
				} s[i][j] = " " s[i][j] s[i] s i j " " {
					s[i][j] = "0";
				} s[i][j] = "0" s[i][j] s[i] s i j "0" for(int i=0; i<15; i++)
			{
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		} int i=0; int i=0; i 0 i<15 i 15 i++ i++ i {
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		} {
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		} for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			} int j=1; int j=1; j 1 j<20 j 20 j+=2 j+=2 j 2 {
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			} {
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			} for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					} int k=0; int k=0; k 0 k<n k n k++ k++ k {
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					} {
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					} if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						} r[k]==i && f[k]==j r[k]==i r[k] r k i f[k]==j f[k] f k j {
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						} int in = Integer.parseInt(s[i][j])+v[k]; in Integer.parseInt(s[i][j])+v[k] Integer.parseInt(s[i][j]) Integer.parseInt Integer s[i][j] s[i] s i j v[k] v k if(in > 9)
							{
								in = 9;
							} in > 9 in 9 {
								in = 9;
							} in = 9 in 9 s[i][j] = in+"" s[i][j] s[i] s i j in+"" in "" for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		} int i=0; int i=0; i 0 i<15 i 15 i++ i++ i {
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		} {
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		} for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			} int j=0; int j=0; j 0 j<20 j 20 j++ j++ j {
				System.out.print(s[i][j]);
			} {
				System.out.print(s[i][j]);
			} System.out.print(s[i][j]) System.out.print System.out System System.out s[i][j] s[i] s i j System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int[] r = new int[n];
		int[] f = new int[n];
		int[] v = new int[n];
		for(int i=0; i<n; i++)
		{
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		}
		
		String[][]  s = new String[15][20];
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		}
			for(int i=0; i<15; i++)
			{
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		}
		
		
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		}
	}
} public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int[] r = new int[n];
		int[] f = new int[n];
		int[] v = new int[n];
		for(int i=0; i<n; i++)
		{
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		}
		
		String[][]  s = new String[15][20];
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		}
			for(int i=0; i<15; i++)
			{
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		}
		
		
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		}
	}
} Main
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int[] r = new int[n];
		int[] f = new int[n];
		int[] v = new int[n];
		for(int i=0; i<n; i++)
		{
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		}
		
		String[][]  s = new String[15][20];
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		}
			for(int i=0; i<15; i++)
			{
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		}
		
		
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		}
	}
}