#include <bits/stdc++.h>
using namespace std;
const int maxint = -1u >> 1;
const double pi = 3.14159265358979323;
const double eps = 1e-8;
int n, tot;
string s, str;
int ans[10];
int conv(string st) {
  int ret = 0;
  for (int i = (0); i < (st.size()); i++) {
    int num = isdigit(st[i]) ? (st[i] - '0') : (10 + st[i] - 'a');
    ret = ret * 16 + num;
  }
  return ret;
}
int main() {
  cin >> n;
  while (n--) {
    cin >> s;
    str.clear();
    tot = 0;
    int tmp = 0;
    memset(ans, 0, sizeof(ans));
    bool flag = false;
    for (int i = (0); i < (s.size()); i++) {
      if (s[i] == ':') {
        ans[tot++] = tmp;
        tmp = 0;
        if (i + 1 < s.size() && s[i + 1] == ':') {
          str = s.substr(i + 2);
          flag = true;
          break;
        }
      } else {
        int dig = isdigit(s[i]) ? (s[i] - '0') : (10 + s[i] - 'a');
        tmp = tmp * 16 + dig;
      }
    }
    if (!flag) ans[tot++] = tmp;
    if (str != "") {
      tot = 8;
      string tt;
      tt.clear();
      for (int i = str.size() - 1; i >= 0; i--) {
        if (str[i] == ':') {
          ans[--tot] = conv(tt);
          tt.clear();
        } else {
          tt = str[i] + tt;
        }
      }
      ans[--tot] = conv(tt);
    }
    for (int i = (0); i < (8); i++)
      printf("%04x%c", ans[i], i == 7 ? '\n' : ':');
  }
  return 0;
}
