#include <iostream>
#include <fstream>
#include <string>
#include <locale>
#include <map>

std::string trim(std::string str) {
    while (!str.empty() && std::isspace(str[str.size()-1])) {
        str.resize(str.size()-1);
    }
    while (!str.empty() && std::isspace(str[0])) {
        str.erase(str.begin());
    }
    return str;
}

int main() {
    typedef std::map<std::string, std::string> keyvalue_t;
    typedef std::map<std::string, keyvalue_t> data_t;
    data_t data;

    //std::ifstream input("file.ini");
    std::istream& input = std::cin; // use above line for real code
    
    std::string line, section;
    while (std::getline(input, line)) {
        line = trim(line);
        if (line.empty()) {
            continue;
        }
        if (line[0] == '[') {
            section = line.substr(1, line.size()-2);
            continue;
        }
        size_t eqpos = line.find('=');
        if (eqpos == std::string::npos) {
            data[section][line];
            continue;
        }
        std::string key = trim(line.substr(0, eqpos)), value = trim(line.substr(eqpos+1));
        data[section][key] = value;
    }
    
    for (data_t::const_iterator section = data.begin() ; section != data.end() ; ++section) {
        std::cout << '[' << section->first << "]\n";
        for (keyvalue_t::const_iterator key = section->second.begin() ; key != section->second.end() ; ++key) {
            std::cout << key->first << '=' << key->second << '\n';
        }
        std::cout << '\n';
    }
}
