<gh_stars>1-10
# -*- coding: utf-8 -*-
# @Author: <NAME>
# @Date:   2016-04-11 22:58:12
# @Last Modified by:   <NAME>
# @Last Modified time: 2016-04-11 22:58:18
from datetime import datetime

if __name__ == "__main__":
    T = int(input())
    pattern = '%a %d %b %Y %H:%M:%S %z'
    for _ in range(T):
        s = datetime.strptime(input(), pattern).timestamp()                
        t = datetime.strptime(input(), pattern).timestamp()
        print(int(abs(s - t)))