class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: A = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.r: B = None
        self.w: B = None
        self.txt = txt

m = A("m")
a = B("a")
e = C("e")
c = C("c")
i = C("i")
l = A("l")
h = C("h")

m.o = i
m.p = i
m.r = l
a.t = c
e.t = a
e.r = a
e.w = a
c.t = a
c.r = a
c.w = a
i.t = a
i.r = a
i.w = a
l.o = e
l.r = m
l.p = c
h.t = a
h.r = a
h.w = a
assert l.o.r.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: A = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.r: B = None
        self.w: B = None
        self.txt = txt

m = A("m")
a = B("a")
e = C("e")
c = C("c")
i = C("i")
l = A("l")
h = C("h")

m.o = i
m.p = i
m.r = l
a.t = c
e.t = a
e.r = a
e.w = a
c.t = a
c.r = a
c.w = a
i.t = a
i.r = a
i.w = a
l.o = e
l.r = m
l.p = c
h.t = a
h.r = a
h.w = a
assert l.o.r.t.w.t.txt == "c"