import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Random;

public class TestsGen {
    static int tests = 0;
    static Random rnd = new Random(3);

    static void out(String... ss) throws FileNotFoundException {
        tests++;
        PrintWriter out = new PrintWriter(String.format("%02d", tests));
        for (String s : ss) {
            out.println(s);
        }
        System.out.print(String.format("[%02d]", tests));
        out.close();
    }

    static void out(Object... ss) throws FileNotFoundException {
        String[] s = new String[ss.length];
        for (int i = 0; i < ss.length; i++) {
            s[i] = ss[i].toString();
        }
        out(s);
    }

    static class Date implements Comparable<Date> {
        final private int[] DAYS_IN_MONTH = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        boolean isNowLastDayOfMonth() {
            if (month == 2 && isNowVisokosnyYear()) {
                return day == DAYS_IN_MONTH[2] + 1;
            }
            return day == DAYS_IN_MONTH[month];
        }

        private boolean isNowVisokosnyYear() {
            if (year % 400 == 0)
                return true;
            if (year % 4 == 0 && year % 100 != 0)
                return true;
            return false;
        }

        private int day, month, year;

        Date(String s) {
            day = Integer.parseInt(s.substring(0, 2));
            month = Integer.parseInt(s.substring(3, 5));
            year = Integer.parseInt(s.substring(6, 10));
            assert 1 <= month && month <= 12;
            assert 1 <= day && day <= DAYS_IN_MONTH[month] + ((isNowVisokosnyYear() && month == 2) ? 1 : 0);
        }

        @Override
        public int compareTo(Date d) {
            if (d.year != year)
                return year - d.year;
            if (d.month != month)
                return month - d.month;
            return day - d.day;
        }

        void next() {
            if (isNowLastDayOfMonth()) {
                if (month == 12) {
                    year++;
                    month = 1;
                } else {
                    month++;
                }
                day = 1;
            } else {
                day++;
            }
        }

        private boolean matches(char a, char b) {
            return a == b || a == '?' || b == '?';
        }

        boolean matches2(char[] a, int b) {
            return matches(a[0], (char) ((b / 10) + '0')) && matches(a[1], (char) ((b % 10) + '0'));
        }

        boolean matches4(char[] a, int b) {
            for (int i = 0; i < 4; i++) {
                if (!matches(a[3 - i], (char) ((b % 10) + '0'))) {
                    return false;
                }
                b /= 10;
            }
            return true;
        }

        boolean matches(char[][] pattern) {
            return matches2(pattern[0], day) && matches2(pattern[1], month) && matches4(pattern[2], year);
        }

        public String toString() {
            return String.format("%02d.%02d.%04d", day, month, year);
        }

        public String failIt(int times) {
            char[] res = toString().toCharArray();
            for (int i = 0; i < times; i++) {
                int pos = rnd.nextInt(res.length);
                if (res[pos] != '.')
                    res[pos] = '?';
            }
            return new String(res);
        }
    }

    static final Date MIN_DATE = new Date("01.01.1970");
    static final Date MAX_DATE = new Date("19.01.2038");

    static Date goodRandomDate() {
        while (true) {
            int dd = rnd.nextInt(31) + 1;
            int mm = rnd.nextInt(12) + 1;
            int yyyy = rnd.nextInt(2039 - 1970) + 1970;
            Date d = new Date(String.format("%02d.%02d.%04d", dd, mm, yyyy));
            if (MIN_DATE.compareTo(d) <= 0 && d.compareTo(MAX_DATE) <= 0)
                return d;
        }
    }

    public static void main(String[] args) throws FileNotFoundException {
        out("?1.?3.2000", "01.03.2000", "31.03.2000");
        out(MIN_DATE, MIN_DATE, MAX_DATE);
        out("??.??.????", MIN_DATE,  MAX_DATE);
        out("??.??.????", MIN_DATE, MIN_DATE);
        out("??.??.????", MAX_DATE, MAX_DATE);
        out("1?.??.????", MIN_DATE, MAX_DATE);
        out("?1.?1.2???", MIN_DATE, MAX_DATE);
        out("??.??.2???", MIN_DATE, MAX_DATE);
        out("??.3?.1???", MIN_DATE, goodRandomDate());
        out("11.11.????", goodRandomDate(), MAX_DATE);
        for (int i = 0; i < 20; i++) {
            Date d1 = goodRandomDate();
            Date d2 = goodRandomDate();
            if (d1.compareTo(d2) > 0) {
                Date tmp = d1;
                d1 = d2;
                d2 = tmp;
            }
            String d0 = goodRandomDate().failIt(rnd.nextInt(10));
            out(d0, d1, d2);
        }
        for (int y = 1995; y < 2006; y++) {
            Date d = new Date(String.format("28.02.%04d", y));
            Date d2 = new Date(String.format("01.03.%04d", y + rnd.nextInt(20)));
            out("??.??.????", d, d2);
        }
    }
}
