#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional> // reference_wrapper

using namespace std;

class Student;
class Prof;
class Subject;

class Dept
{
	string name;
	vector<reference_wrapper<Student>> students;
	vector<reference_wrapper<Prof>> profs;
public:
	Dept( string deptname ) : name(deptname) {}
	void addProf( Prof &p ) { profs.push_back(p); }
	void addStudent( Student &s ) { students.push_back(s); }
};

class Prof
{
	string name;
	Dept &dept;
	vector<reference_wrapper<Student>> students;
	vector<reference_wrapper<Subject>> subjects;
public:
	Prof( string name, Dept &dept ) : name(name), dept(dept) { dept.addProf(*this); }
	void addStudent( Student &s ) { students.push_back(s); }
	void addSubject( Subject &s ) { subjects.push_back(s); }
};

class Subject
{
	string name;
	Prof &prof;
	vector<reference_wrapper<Student>> students;
public:
	Subject( string name, Prof &p ) : name(name), prof(p) { p.addSubject(*this); }
	void addStudent( Student &s ) { students.push_back(s); }
};

class Student
{
	string name;
	Dept &dept;
	Prof &prof;
	vector<reference_wrapper<Subject>> subjects;
public:
	Student(string name, Dept &dept, Prof &prof) : name(name), dept(dept), prof(prof) 
		{ dept.addStudent(*this); prof.addStudent(*this); }
	void enroll( Subject &s ) { subjects.push_back(s); s.addStudent(*this); }
};

int main() 
{
	Dept ce("Computer Engineering");
	Prof shin("Minho Shin", ce);
	Prof cho("Sehyung Cho", ce);
	Student s1("Chulsoo Kim", ce, shin);
	Student s2("Miyoung Choi", ce, cho);
	Student s3("Kimoon Ahn", ce, shin);
	Subject cpp("C++ Programming", shin);
	Subject java("Java Programming", cho);
	s1.enroll( cpp );
	s2.enroll( java );
	s3.enroll( java );
}