#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    vector<string> block;
    string buffer = "";
    vector<string> ans;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] != ':') buffer += s[i];
      if (s[i] == ':' && s[i - 1] == ':') {
        block.push_back("::");
        buffer = "";
        continue;
      }
      if (i == s.length() - 1 || s[i] == ':') {
        block.push_back(buffer);
        buffer = "";
      }
    }
    int re = 8 - block.size();
    int count = 7;
    for (int i = 0; i < block.size(); i++) {
      if (block[i] == "::") {
        for (int j = 0; j <= re; j++) {
          ans.push_back("0000");
        }
        continue;
      }
      if (block[i].length() == 4)
        ans.push_back(block[i]);
      else {
        string b_ans = "";
        for (int j = 0; j < 4 - block[i].length(); j++) b_ans += "0";
        b_ans += block[i];
        ans.push_back(b_ans);
      }
    }
    for (auto x : ans) {
      cout << x;
      if (--count >= 0) cout << ":";
    }
    cout << "\n";
  }
}
