#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
#include<algorithm>
using namespace std;
#define N 1010000
#define INF 0x3f3f3f3f
int yearday[N];
int IsLeap(int year) ///判断闰年
{
return ((year%4==0&&year%100!=0) || year%400==0);
}
void init()
{
yearday[0]=0;
for(int i=1; i<=1000000; i++)
yearday[i]=yearday[i-1]+(IsLeap(i-1)==1 ? 366 : 365);
}
int Day(int y,int m,int d) ///判断该天是当年的第多少天。
{
int k,leap;
int tab[2][13]={{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
leap=IsLeap(y);
for(k=1;k<m;k++)
{
d=d+tab[leap][k];
}
return d;
}
int main()
{
int T, y1, m1, d1, y2, m2, d2, sum;
init();
scanf("%d", &T);
while(T--)
{
scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2);
sum=0;
sum+=yearday[y2]-yearday[y1];
sum-=Day(y1,m1,d1);
sum+=Day(y2,m2,d2);
printf("%d\n", sum);
}
return 0;
}