/**
 * birthdays.java
 * Logan Kriete
 * 7/25/10
 * Solution for Birth Days BHCSI 2010 contest #3 problem
 */

import java.util.*;
import java.io.*;

public class birthdays {

	public static void main(String[] args) throws FileNotFoundException {
		
		// create our file scanner
    	File f = new File("birthdays.in");
    	Scanner fin = new Scanner(f);
    	
    	// find out how many birth scenarios we're processing
    	int numCases = fin.nextInt();
    	
    	// loop through numCases times
    	for (int i = 0; i < numCases; i++) {
    		
    		// read in the data for when Brad was born
    		int birthMonth = fin.nextInt();
    		int birthDay = fin.nextInt();
    		int birthYear = fin.nextInt();
    		
    		System.out.println("Brad was born on " + birthMonth + "/" + birthDay + "/" + birthYear+".");
    		
    		// read in the data for the "current" date
    		int curMonth = fin.nextInt();
    		int curDay = fin.nextInt();
    		int curYear = fin.nextInt();
    		
    		System.out.println("It is now " + curMonth + "/" + curDay + "/" + curYear+".");
    		
    		// create our variable to store how many days have passed and how many birthdays he had
    		int days = 0;
    		int numBirthdays = 0;
    		
    		// if the current day is in the same year/month, there's no need to do all of this processing
    		if (curMonth == birthMonth && curYear == birthYear) {
    			days += curDay - birthDay;
    		}
    		else { // do all the processing
    			// add the days up to the next month after his birth
	    		days += numDays(birthMonth, birthYear) - birthDay;
	    		
	    		// loop through the months and years up to the current month
	    		int month = birthMonth+1;
	    		int year = birthYear;
	    		while (month != curMonth || year != curYear) {
	    			days += numDays(month, year); // add to the day count the number of days in this month and year
	    			
	    			// increase the birthday counter if it's his birth month and this particular month/year has his birth day in it
	    			if (month == birthMonth && numDays(month, year) >= birthDay)
	    				numBirthdays++;
	    			
	    			// go to the next month & year if applicable
	    			if (month == 12) {
	    				month = 1;
	    				year++;
	    			}
	    			else {
	    				month++;
	    			}
	    		}
	    		
	    		// finally add up the days to the current day, month, and year
	    		days += curDay;
	    		// and if his/her birthday occurred in the last month of the span, increase numBirthdays!
	    		if (curDay >= birthDay && curMonth == birthMonth && curYear != birthYear) numBirthdays++;
	    		
    		}
    		
    		// output the answer
    		System.out.println("Brad is now " + days + " days old and he has had " + numBirthdays + " birthdays.\n");
    		
    	}
		
	}
	
	// takes in a month and year and returns the number of days in that month of that year
	// for example, numDays(1, 2000) = 31 because there was 31 days in January of 2000
	public static int numDays(int month, int year) {
		switch (month) {
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				return 31;
			case 4:
			case 6:
			case 9:
			case 11:
				return 30;
			case 2:
				if (((year%4==0)&&!(year%100==0))||(year%400==0))
					return 29;
				return 28;
			default:
				return 0;
		}
	}

}