#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

// our "input" stream:
std::istringstream in(
R"(CallStarted_Cap900 10.160.159.37 32514 unid to 10.9.11.66 32740 RABIA-TUJIMET-CERYAN at 2015 04 21 16 33 54 921.waa_end
CallStartedAck_Cap900 10.160.159.37 32514 unid to 10.9.11.66 32740 RABIA-TUJIMET-CERYAN at 2015 04 21 16 33 54 921.waa_end
CallStarted_Cap900 10.9.11.61 32572 3051905 to 10.9.11.18 39994 79970056 at 2015 04 21 16 33 54 994.waa_end
CallStartedAck_Cap900 10.9.11.61 32572 3051905 to 10.9.11.18 39994 79970056 at 2015 04 21 16 33 54 994.waa_end
CallStarted_Cap900 10.160.167.34 32514 unid to 10.9.11.61 32580 RGorusme at 2015 04 21 16 33 55 035.waa_end
CallStartedAck_Cap900 10.160.167.34 32514 unid to 10.9.11.61 32580 RGorusme at 2015 04 21 16 33 55 035.waa_end
)");

bool less_than(const std::string& a, const std::string& b)
{
    // error checking should be done here.
    return a.substr(a.find(' ')) < b.substr(b.find(' '));
}

bool equal(const std::string& a, const std::string& b)
{
    // error checking should be done here.
    return a.substr(a.find(' ')) == b.substr(b.find(' '));
}

int main()
{
    std::ostream& out = std::cout;

    std::string line;
    std::vector<std::string> lines;
    while (getline(in, line))
        lines.push_back(line);

    std::sort(lines.begin(), lines.end(), less_than);

    bool previous_output = false;
    for (std::size_t i = 0, j = 0; i != lines.size(); i = j)
    {
        if (previous_output)
            out << std::string(40, '-') << '\n';

        while (j != lines.size() && equal(lines[i], lines[j]))
            out << lines[j++] << '\n';

        previous_output = true;
    }
}