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

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

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

e = A("e")
d = B("d")
n = C("n")
j = A("j")

e.t = j
e.p = j
e.w = n
d.w = n
d.t = n
n.o = j
j.t = e
j.p = e
j.w = n
assert d.t.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: A = None
        self.w: C = None
        self.txt = txt

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

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

e = A("e")
d = B("d")
n = C("n")
j = A("j")

e.t = j
e.p = j
e.w = n
d.w = n
d.t = n
n.o = j
j.t = e
j.p = e
j.w = n
assert d.t.o.w.txt == "n"