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

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

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

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

h = A("h")
k = B("k")
i = C("i")
l = D("l")

h.t = i
h.p = i
h.z = i
k.p = i
k.u = i
k.t = h
i.t = k
l.v = i
assert l.v.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: C = None
        self.z: C = None
        self.txt = txt

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

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

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

h = A("h")
k = B("k")
i = C("i")
l = D("l")

h.t = i
h.p = i
h.z = i
k.p = i
k.u = i
k.t = h
i.t = k
l.v = i
assert l.v.t.u.t.txt == "k"