#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, m(0), s;
  cin >> n;
  for (s = n; s > 0; s--) {
    char a[40] = {0}, b[4][8] = {0};
    int x(3), y(0);
    scanf("%s", a);
    for (j = strlen(a) - 1; j >= 0; j--) {
      if (a[j] == ':') m += 1;
    }
    for (j = strlen(a) - 1; j >= 0; j--) {
      if (a[j] != ':')
        b[x--][y] = a[j];
      else {
        x = 3;
        y++;
      }
      if (a[j] == ':' && a[j - 1] == ':') {
        y = y + 7 - m;
      }
    }
    for (j = 7; j >= 0; j--) {
      for (i = 0; i < 4; i++) {
        if (b[i][j] == 0)
          cout << "0";
        else
          cout << b[i][j];
      }
      if (j) cout << ":";
    }
    cout << endl;
    m = 0;
  }
  return 0;
}
