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

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

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

m = A("m")
n = B("n")
l = C("l")
d = B("d")
k = C("k")
g = A("g")
b = B("b")
e = C("e")

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

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

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

m = A("m")
n = B("n")
l = C("l")
d = B("d")
k = C("k")
g = A("g")
b = B("b")
e = C("e")

m.t = d
n.x = g
n.p = e
l.v = g
d.x = m
d.p = k
k.v = g
g.t = b
b.x = m
b.p = e
e.v = g
assert l.v.t.p.txt == "e"