#include <bits/stdc++.h>
using namespace std;
char f[123][123];
int n, m, i, j, pos;
string s;
void doit(string &s) {
  bool have = false;
  for (int i = 0; i < int(s.size()) - 1; ++i)
    if (s[i] == ':' && s[i + 1] == ':') have = true;
  int u, w, i;
  if (!have) {
    int j, i = 0, u, w;
    string ans = "";
    while (i < s.size()) {
      j = i;
      string t = "";
      while (j < s.size() && s[j] != ':') {
        t = t + s[j];
        j++;
      }
      if (t.size() < 4) {
        u = t.size();
        for (w = 0; w < 4 - u; ++w) t = '0' + t;
      }
      ans = ans + t;
      if (j != s.size()) ans += ':';
      i = j + 1;
    }
    s = ans;
    return;
  } else {
    string ans;
    pos = 0;
    for (i = 0; i < (int)(s.size()) - 1; ++i)
      if (s[i] == ':' && s[i + 1] == ':') {
        pos = i;
        break;
      }
    int res = 0;
    for (i = 0; i < s.size(); ++i) {
      if (s[i] != ':') ++res;
      j = i;
      while (j < s.size() && s[j] != ':') ++j;
      i = j;
    }
    int ad = 8 - res;
    if (pos == 0) {
      ans = "";
      for (i = 0; i < ad; ++i) ans = ans + "0000:";
      ans.erase(ans.size() - 1, 1);
      i = 2;
      while (i < s.size()) {
        j = i;
        string t = "";
        while (j < s.size() && s[j] != ':') {
          t = t + s[j];
          j++;
        }
        if (t.size() < 4) {
          u = t.size();
          for (w = 0; w < 4 - u; ++w) t = '0' + t;
        }
        ans = ans + ':' + t;
        i = j + 1;
      }
    } else {
      string t;
      i = 0;
      while (i < s.size()) {
        if (s[i] == ':') {
          for (j = 0; j < ad; ++j) ans = ans + "0000:";
          i++;
        } else {
          t = "";
          j = i;
          while (j < s.size() && s[j] != ':') {
            t = t + s[j];
            j++;
          }
          u = t.size();
          for (w = 0; w < 4 - u; ++w) t = '0' + t;
          i = j + 1;
          ans = ans + t + ':';
        }
      }
    }
    if (ans[ans.size() - 1] == ':') ans.erase(ans.size() - 1, 1);
    s = ans;
  }
}
int main() {
  cin >> n;
  getline(cin, s);
  for (i = 0; i < n; ++i) {
    getline(cin, s);
    doit(s);
    cout << s << endl;
  }
}
