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

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

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

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

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

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

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

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

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