#include <bits/stdc++.h>
using namespace std;
void prntVec(vector<int> &a) {
  for (auto i : a) cout << i << ' ';
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s, ans;
    cin >> s;
    vector<string> arr;
    string temp;
    int cnt = 0;
    int idx = -1;
    for (int i = s.size() - 1; i >= 0; i--) {
      if (s[i] == ':' && s[i - 1] == ':') {
        idx = cnt;
        continue;
      } else if (s[i] == ':') {
        cnt++;
        while (temp.size() < 4) temp.push_back('0');
        arr.push_back(temp);
        temp = "";
      } else {
        temp.push_back(s[i]);
      }
    }
    while (temp.size() < 4) temp.push_back('0');
    arr.push_back(temp);
    for (int i = arr.size() - 1; i >= 0; i--) {
      if (i == idx) {
        for (int k = 0; k < 8 - arr.size(); k++) {
          ans += "0000:";
        }
      }
      for (int j = 3; j >= 0; j--) {
        ans.push_back(arr[i][j]);
      }
      if (i != 0) ans.push_back(':');
    }
    cout << ans << "\n";
  }
  return 0;
}
