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

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

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

d = A("d")
i = B("i")
e = C("e")
m = C("m")
h = A("h")

d.t = i
d.p = e
i.z = m
i.x = e
e.v = m
m.v = e
h.t = i
h.p = e
assert i.z.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: C = None
        self.txt = txt

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

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

d = A("d")
i = B("i")
e = C("e")
m = C("m")
h = A("h")

d.t = i
d.p = e
i.z = m
i.x = e
e.v = m
m.v = e
h.t = i
h.p = e
assert i.z.v.v.v.txt == "e"