#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    string word = "";
    vector<string> words;
    long long cnt = 0;
    for (long long i = 0; i < s.size(); i++) {
      if (s[i] == ':') {
        if (word != "") words.push_back(word), cnt++, word = "";
        if (s[i + 1] == ':') i++, words.push_back("");
      } else
        word += s[i];
    }
    if (word != "") words.push_back(word), cnt++;
    cnt = 8 - cnt;
    for (long long i = 0; i < words.size(); i++) {
      if (words[i] == "") {
        for (long long j = 0; j < cnt; j++) {
          cout << "0000";
          if (j < cnt - 1) cout << ":";
        }
      } else {
        for (long long j = 0; j < 4 - words[i].size(); j++) cout << "0";
        cout << words[i];
      }
      if (i < words.size() - 1) cout << ":";
    }
    cout << "\n";
  }
  return 0;
}
