#include <bits/stdc++.h>
using namespace std;
int ToInt(string& s, int len) {
  int r = 0;
  for (int i = 0, max_ = (len); i < max_; ++i) {
    r *= 10;
    r += s[i] - '0';
  }
  return r;
}
int GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
int LCM(int a, int b) { return a * (b / GCD(a, b)); }
long long Pow(long long n, long long e) {
  if (e == 0) return 1;
  if (e == 1)
    return n;
  else if (e & 1) {
    long long t = Pow(n, e / 2);
    return n * t * t;
  } else {
    long long t = Pow(n, e / 2);
    return t * t;
  }
}
int main() {
  char b[200];
  string s, t;
  vector<string> str;
  int T;
  scanf("%d", &T);
  gets(b);
  while (T--) {
    gets(b);
    s = b;
    t = s;
    str.clear();
    for (int i = 0, max_ = ((int)(t).size()); i < max_; ++i)
      if (t[i] == ':') t[i] = ' ';
    stringstream ss(t);
    while (ss >> t) str.push_back(t);
    int c = 0, pos = -1, id = -1;
    for (int i = 0, max_ = ((int)(s).size()); i < max_; ++i)
      if (s[i] == ':') {
        if (i + 1 < (int)(s).size() && s[i + 1] == ':') {
          pos = i;
          break;
        }
      }
    if (pos > -1) {
      if (pos == 0)
        id = 0;
      else {
        int num = 0;
        for (int i = 0, max_ = (pos); i < max_; ++i)
          if (s[i] == ':') ++num;
        id = 1 + num;
      }
    }
    bool first = true;
    for (int i = 0, max_ = (id); i < max_; ++i) {
      if (!first) printf(":");
      for (int j = 0, max_ = (4 - (int)(str[i]).size()); j < max_; ++j)
        printf("0");
      printf("%s", str[i].c_str());
      first = false;
    }
    if (id != -1) {
      for (int i = 0, max_ = (8 - (int)(str).size()); i < max_; ++i) {
        if (!first) printf(":");
        printf("0000");
        first = false;
      }
    }
    for (int i = (max(0, id)), max_ = ((int)(str).size()); i < max_; ++i) {
      if (!first) printf(":");
      for (int j = 0, max_ = (4 - (int)(str[i]).size()); j < max_; ++j)
        printf("0");
      printf("%s", str[i].c_str());
      first = false;
    }
    printf("\n");
  }
  return 0;
}
