#include <bits/stdc++.h>
using namespace std;
vector<string> ip;
vector<string> ret;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    string ipAddress;
    cin >> ipAddress;
    string temp;
    ip.clear();
    ret.clear();
    bool zero = true;
    for (int j = 0; j < ipAddress.size(); j++) {
      if (ipAddress[j] != ':')
        temp += ipAddress[j];
      else {
        if (zero && temp == "") {
          ip.push_back(temp);
          zero = false;
        } else if (temp != "") {
          ip.push_back(temp);
        }
        temp.clear();
      }
    }
    if (temp != "") ip.push_back(temp);
    temp.clear();
    zero = true;
    for (int j = 0; j < ip.size(); j++) {
      if (ip[j].size() != 0) {
        for (int k = 0; k < 4 - ip[j].size(); k++) temp += "0";
        temp += ip[j];
        ret.push_back(temp);
        temp.clear();
      } else if (zero) {
        zero = false;
        for (int k = 0; k < 8 - ip.size() + 1; k++) {
          temp = "0000";
          ret.push_back(temp);
          temp.clear();
        }
      }
    }
    cout << ret[0];
    for (int i = 1; i < 8; i++) cout << ":" + ret[i];
    cout << endl;
  }
  return 0;
}
