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

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

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

e = A("e")
b = B("b")
m = C("m")
c = A("c")
d = C("d")
j = C("j")
n = B("n")

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

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

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

e = A("e")
b = B("b")
m = C("m")
c = A("c")
d = C("d")
j = C("j")
n = B("n")

e.p = m
e.v = d
e.w = n
b.t = e
b.p = n
m.x = n
m.o = b
c.p = m
c.v = j
c.w = b
d.x = b
d.o = n
j.x = n
j.o = n
n.t = e
n.p = b
assert m.x.t.p.x.t.txt == "e"