#include <bits/stdc++.h>
using namespace std;
void solve() {
  char ch[50];
  scanf("%s", &ch);
  vector<string> v;
  string cur;
  for (int i = 0; ch[i]; ++i) {
    if (ch[i] != ':') {
      cur += ch[i];
    } else if (cur.length()) {
      v.push_back(cur);
      cur.resize(0);
    } else if (i) {
      v.push_back("::");
    }
  }
  if (cur.length()) {
    v.push_back(cur);
  }
  for (int i = 0; i < v.size(); ++i) {
    if (i) {
      printf(":");
    }
    if (v[i] != "::") {
      reverse(v[i].begin(), v[i].end());
      while (v[i].size() < 4) {
        v[i] += '0';
      }
      reverse(v[i].begin(), v[i].end());
      cout << v[i];
    } else {
      int q = 8 - int(v.size());
      printf("0000");
      for (int i = 0; i < q; ++i) {
        printf(":0000");
      }
    }
  }
  puts("");
}
int main(int argc, char *argv[]) {
  int n;
  scanf("%d", &n);
  while (n--) {
    solve();
  }
  return 0;
}
