#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int checkdate(int, int, int, int, int, int, int, int);
int /*<<< orphan*/ printf(char *, int, long long);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int i, n, d1, m1, y1, d2, m2, y2, c1, c2, days, ret;
  long long int sum;
  while (1) {
    ret = 0;
    days = 0;
    sum = 0;
    scanf("%d", &n);
    if (n == 0)
      break;
    else
      scanf("%d%d%d%d", &d1, &m1, &y1, &c1);
    for (i = 1; i < n; i++) {
      scanf("%d%d%d%d", &d2, &m2, &y2, &c2);
      ret = checkdate(d1, m1, y1, c1, d2, m2, y2, c2);
      sum += ret;
      if (ret != 0)
        days++;
      d1 = d2;
      m1 = m2;
      y1 = y2;
      c1 = c2;
    }
    printf("%d %lld\n", days, sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
movq   $0x0,-0x40(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1176 <main+0x46>
jmp    124d <main+0x11d>
lea    0xe83(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x28(%rbp),%r8
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1235 <main+0x105>
lea    0xe52(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
lea    -0x2c(%rbp),%r8
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x24(%rbp),%r10d
mov    -0x2c(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <checkdate@plt>
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     120f <main+0xdf>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119b <main+0x6b>
mov    -0x30(%rbp),%esi
mov    -0x40(%rbp),%rdx
lea    0xdc6(%rip),%rdi
call   1040 <printf@plt>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xec1(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
je     126e <main+0x13e>
lea    0xe9d(%rip),%r15
lea    0x18(%rsp),%rbx
lea    0x10(%rsp),%r12
jmp    11a4 <main+0x74>
nop
xor    %ebp,%ebp
xor    %r13d,%r13d
lea    0xe8d(%rip),%rdi
mov    %ebp,%esi
mov    %r13,%rdx
call   1040 <printf@plt>
lea    0xe79(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
je     126e <main+0x13e>
mov    %r15,%rdi
lea    0x24(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x1c(%rsp),%rcx
lea    0xc(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x2,0x4(%rsp)
jl     1170 <main+0x40>
mov    $0x1,%r14d
xor    %r13d,%r13d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbx,%rsi
lea    0x14(%rsp),%rdx
mov    %r12,%rcx
lea    0x8(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x24(%rsp),%edi
mov    0x20(%rsp),%esi
mov    0x1c(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    0x14(%rsp),%r9d
mov    0x10(%rsp),%r10d
mov    %rbx,%rax
mov    0x8(%rsp),%ebx
push   %rbx
mov    %rax,%rbx
push   %r10
call   1030 <checkdate@plt>
add    $0x10,%rsp
cltq
add    %rax,%r13
cmp    $0x1,%eax
sbb    $0xffffffff,%ebp
mov    0x18(%rsp),%eax
mov    %eax,0x24(%rsp)
mov    0x14(%rsp),%eax
mov    %eax,0x20(%rsp)
mov    0x10(%rsp),%eax
mov    %eax,0x1c(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,0xc(%rsp)
add    $0x1,%r14d
cmp    0x4(%rsp),%r14d
jl     11e0 <main+0xb0>
jmp    1175 <main+0x45>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"%d%d%d%d\00"
@.str.2 = [9 x i8] c"%d %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
store i32 0, i32* %1
br label %15
15: ; preds = %0, %55
store i32 0, i32* %13
store i32 0, i32* %12
store i64 0, i64* %14
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
br label %59
20: ; preds = %15
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %10)
br label %22
22: ; preds = %20
store i32 1, i32* %2
br label %23
23: ; preds = %52, %22
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %55
27: ; preds = %23
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8, i32* %9, i32* %11)
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = load i32, i32* %10
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = load i32, i32* %11
%37 = call i32 @checkdate(i32 %29, i32 %30, i32 %31, i32 %32, i32 %33, i32 %34, i32 %35, i32 %36)
store i32 %37, i32* %13
%38 = load i32, i32* %13
%39 = sext i32 %38 to i64
%40 = load i64, i64* %14
%41 = add nsw i64 %40, %39
store i64 %41, i64* %14
%42 = load i32, i32* %13
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %27
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 1
store i32 %46, i32* %12
br label %47
47: ; preds = %44, %27
%48 = load i32, i32* %7
store i32 %48, i32* %4
%49 = load i32, i32* %8
store i32 %49, i32* %5
%50 = load i32, i32* %9
store i32 %50, i32* %6
%51 = load i32, i32* %11
store i32 %51, i32* %10
br label %52
52: ; preds = %47
%53 = load i32, i32* %2
%54 = add nsw i32 %53, 1
store i32 %54, i32* %2
br label %23
55: ; preds = %23
%56 = load i32, i32* %12
%57 = load i64, i64* %14
%58 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %56, i64 %57)
br label %15
59: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"%d%d%d%d\00"
@.str.2 = [9 x i8] c"%d %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i32* %1 to i8*
%11 = bitcast i32* %2 to i8*
%12 = bitcast i32* %3 to i8*
%13 = bitcast i32* %4 to i8*
%14 = bitcast i32* %5 to i8*
%15 = bitcast i32* %6 to i8*
%16 = bitcast i32* %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, 0
br i1 %21, label %59, label %22
22: ; preds = %0, %52
%23 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %8)
%24 = load i32, i32* %1
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %52
26: ; preds = %22, %26
%27 = phi i64 [ %41, %26 ], [ 0, %22 ]
%28 = phi i32 [ %44, %26 ], [ 0, %22 ]
%29 = phi i32 [ %49, %26 ], [ 1, %22 ]
%30 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6, i32* %7, i32* %9)
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = load i32, i32* %8
%35 = load i32, i32* %5
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = load i32, i32* %9
%39 = call i32 @checkdate(i32 %31, i32 %32, i32 %33, i32 %34, i32 %35, i32 %36, i32 %37, i32 %38)
%40 = sext i32 %39 to i64
%41 = add nsw i64 %27, %40
%42 = icmp ne i32 %39, 0
%43 = zext i1 %42 to i32
%44 = add nuw nsw i32 %28, %43
%45 = load i32, i32* %5
store i32 %45, i32* %2
%46 = load i32, i32* %6
store i32 %46, i32* %3
%47 = load i32, i32* %7
store i32 %47, i32* %4
%48 = load i32, i32* %9
store i32 %48, i32* %8
%49 = add nuw nsw i32 %29, 1
%50 = load i32, i32* %1
%51 = icmp slt i32 %49, %50
br i1 %51, label %26, label %52
52: ; preds = %26, %22
%53 = phi i32 [ 0, %22 ], [ %44, %26 ]
%54 = phi i64 [ 0, %22 ], [ %41, %26 ]
%55 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %53, i64 %54)
%56 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%57 = load i32, i32* %1
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %22
59: ; preds = %52, %0
ret i32 0
}