#include <iostream>
#include <deque>

using namespace std;

class Person
{
    friend void print(deque<Person> &dq);

private:
    string name;
    int age;

public:
    Person(string name, int age) : name(name), age(age) {}
};

void print(deque<Person> &dq)
{
    deque<Person>::iterator it = dq.begin();
    while (it != dq.end())
    {
        cout << (*it).name << ", " << (*it).age << endl;
        ;
        it++;
    }
}

int main()
{
    deque<Person> dq;
    dq.push_front(Person("张三", 18));
    dq.push_back(Person("李四", 19));
    dq.push_front(Person("王五", 20));
    print(dq);

    cout << "--------" << endl;
    dq.pop_back();
    dq.pop_front();
    print(dq);

    return 0;
}