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

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

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

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

a = A("a")
n = B("n")
h = C("h")
e = D("e")
b = A("b")
m = B("m")
i = A("i")

a.t = h
a.u = i
n.r = h
h.z = n
e.t = h
e.v = a
b.t = h
b.u = a
m.r = h
i.t = h
i.u = b
assert i.t.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: A = None
        self.txt = txt

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

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

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

a = A("a")
n = B("n")
h = C("h")
e = D("e")
b = A("b")
m = B("m")
i = A("i")

a.t = h
a.u = i
n.r = h
h.z = n
e.t = h
e.v = a
b.t = h
b.u = a
m.r = h
i.t = h
i.u = b
assert i.t.z.r.txt == "h"