#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, rez[8];
  int n;
  cin >> n;
  for (int gn = 0; gn < n; gn++) {
    cin >> s;
    int p = -1, mr = 0, k = 0;
    for (int i = 0; i < 8; i++) {
      rez[i] = "0000";
    }
    for (int i = 0; i < s.size(); i++) {
      (s[i] == ':') && (mr++);
    }
    s = s + ':';
    if (s == "::") {
      cout << "0000:0000:0000:0000:0000:0000:0000:0000";
    }
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == ':') {
        if (i - p - 1 != 0) {
          for (int j = 3; j > 4 - i + p; j--) {
            rez[k][j] = s[p - 4 + i - p + j];
          }
          k++;
        } else {
          if (i == 0) {
            i++;
            k += 9 - mr;
          } else {
            k += 8 - mr;
          }
        }
        p = i;
      }
    }
    for (int i = 0; i < 8; i++) {
      cout << rez[i];
      i < 7 && cout << ":";
    }
    cout << endl;
  }
  return 0;
}
