#include <iostream.h>

template <class Item> class border {
 public:
  border(Item &aIt) { it = &aIt; };
  void draw() {
    cout << "border"; 

    it->draw();
  };
  private:
    Item *it;
};

template <class Item> class title {
 public:
  title(Item &aIt) { it = &aIt;};
  void draw() {
    cout << "title"; 

    it->draw();
  };
  private:
    Item *it;
};


class window {
 public:
  void draw () { cout << "window";};
};


main () {

  window aW;
  title<window> aTW(aW);
  border< title<window> > aBTW(aTW);
  border<window> aBW(aW);
 title< border<window> > aTBW(aBW);
  aW.draw();
  aTW.draw();
  aBTW.draw();
  aTBW.draw();
}

