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.util.*;
import java.math.*;
import java.lang.*;
import java.io.*;

public class b1
{
    //static int MOD = 1000000009;
    public static void main(String[] args) {
        InputReader in      = new InputReader(System.in);
        OutputWriter out    =   new OutputWriter(System.out);
        int n = in.readInt();
            String str = in.readString();
            String[] sarr = str.split(":");
            int[] arr = new int[2];
            arr[0] = Integer.parseInt(sarr[0]);
            arr[1] = Integer.parseInt(sarr[1]);
            if(!(arr[1]<=59 && arr[1]>=0))
            {
                arr[1] = (arr[1]%10)+10;
            }
            if(n==12)
            {
                if(arr[0]==0)
                {
                    arr[0] = 1;
                }
                else if(arr[0]>12)
                {
                    if(arr[0]%10==0)
                    {
                        arr[0] = 10;
                    }
                    else
                    {
                        arr[0] = (arr[0]%10);
                    }
                }
            }
            else if(n==24)
            {
                if(arr[0]>23)
                {
                    arr[0] = 10 + (arr[0]%10);
                }
            }

            String str1 = String.valueOf(arr[0]);
            String str2 = String.valueOf(arr[1]);
            if(str1.length()==1)
                str1 = "0"+str1;
            if(str2.length()==1)
                str2 = "0"+str2;

            out.printLine(str1+":"+str2);
        
        out.flush();
        out.close();
    }

     
}


class InputReader {
 
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
 
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
 
        public int read() {
            if (numChars == -1)
                throw new NumberFormatException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new NumberFormatException();
                }
                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 NumberFormatException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        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 boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
 
        public String next() {
            return readString();
        }
 
        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
 
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();
        }
 
        }
 
class IOUtils {
 
        public static int[] readIntArray(InputReader in, int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
                array[i] = in.readInt();
            return array;
        }
 
        }