#include <bits/stdc++.h>
using namespace std;
int n;
string s;
vector<string> List;
void MakeItTrue(string a) {
  vector<string> b;
  int p = 0, g = 0;
  if (a[0] == ':') {
    p = 2;
    b.push_back("");
  }
  for (int i = p; i < a.size(); i++) {
    if (a[i] == ':' || i == a.size() - 1) {
      int h = (i == a.size() - 1 && a[i] != ':');
      b.push_back(a.substr(p, i - p + h));
      if (b[b.size() - 1].size() > 0) g++;
      p = i + 1;
    }
  }
  for (int i = 0; i < b.size(); i++) {
    if (b[i].size() > 0)
      while (b[i].size() < 4) b[i] = "0" + b[i];
    else
      for (int j = g; j < 8; j++) {
        b[i] += "0000";
        if (j != 7) b[i] += ":";
      }
  }
  for (int i = 0; i < b.size(); i++) {
    cout << b[i];
    if (i < b.size() - 1) cout << ":";
  }
  cout << endl;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    MakeItTrue(s);
  }
  return 0;
}
