#include <stdio.h>
#include <stdlib.h>

// write your code here......

int main() {
    int n,i,t,h,m,s,t0;
    t0 = 0;
    t = 0;
    i = 0;
    scanf("%d",&n);
    while(i < n){
        scanf("%d",&t);
        t0 += t;
        h = t0 / 3600;
        m = (t0 % 3600) / 60;
        s = (t0 % 3600) % 60;
        printf("%d %d %d\n",h,m,s);
        i++;
    }
    return 0;
}