Problem: You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.

You are given a time in format HH:MM that is currently displayed on the broken clock. Your goal is to change minimum number of digits in order to make clocks display the correct time in the given format.

For example, if 00:99 is displayed, it is enough to replace the second 9 with 3 in order to get 00:39 that is a correct time in 24-hours format. However, to make 00:99 correct in 12-hours format, one has to change at least two digits. Additionally to the first change one can replace the second 0 with 1 and obtain 01:39.

Input

The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively.

The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.

Output

The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.

Examples

Input

24
17:30


Output

17:30


Input

12
17:30


Output

07:30


Input

24
99:99


Output

09:09

Solution (in JAVA):

Solution:
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class A {
	public static void main(String[] args) {
		FastScannerA sc = new FastScannerA(System.in);
		
		int format = sc.nextInt();
		String time = sc.next();
		StringBuilder sb = new StringBuilder();
		if(format == 12){
			char c1 = time.charAt(0);
			char c2 = time.charAt(1);
			if(c1 == '0'){
				if(c2 != '0'){
					//do nothing
					sb.append(c1);
					sb.append(c2);
				}
				else{
					sb.append("10");
				}
			}
			else if(c1 == '1'){
				if(c2 == '0' || c2 == '1' || c2 == '2'){
					//do nothing
					sb.append(c1);
					sb.append(c2);
				}
				else{
					sb.append("10");
				}
			}
			else{
				if(c2 == '0'){
					sb.append("10");
				}
				else{
					sb.append('0');
					sb.append(c2);
				}
			}
			
			sb.append(':');
			
			char m = time.charAt(3);
			int mm = m - '0';
			if(mm >= 6){
				sb.append('5');
				sb.append(time.charAt(4));
			}
			else{
				sb.append(m);
				sb.append(time.charAt(4));
			}
		}
		else{
			//24 hours
			char c1 = time.charAt(0);
			char c2 = time.charAt(1);
			if(c1 == '0' || c1 == '1'){
				//do nothing
				sb.append(c1);
				sb.append(c2);
			}
			else if(c1 == '2'){
				if(c2 == '0' || c2 == '1' || c2 == '2' || c2 == '3'){
					//do nothing
					sb.append(c1);
					sb.append(c2);
				}
				else{
					sb.append("20");
				}
			}
			else{
				sb.append("0");
				sb.append(c2);
			}
			
			sb.append(':');
			
			char m = time.charAt(3);
			int mm = m - '0';
			if(mm >= 6){
				sb.append('5');
				sb.append(time.charAt(4));
			}
			else{
				sb.append(m);
				sb.append(time.charAt(4));
			}
		}
		System.out.println(sb);
	}
}

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

    public FastScannerA(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 nextInt()
    {
        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 String next()
    {
        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();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isLineEndChar(c));
        return res.toString();
    }    
    
    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, nextInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        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 {
            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 c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
    
    public boolean isLineEndChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == '\n' || c == '\r' || c == -1;
    }

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