class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.z: A = None
        self.txt = txt

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

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

l = A("l")
k = B("k")
a = C("a")
b = D("b")
j = C("j")

l.z = b
k.u = b
k.z = l
a.p = b
a.s = j
b.t = j
b.v = l
j.p = b
j.s = a
assert k.u.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.z: A = None
        self.txt = txt

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

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

l = A("l")
k = B("k")
a = C("a")
b = D("b")
j = C("j")

l.z = b
k.u = b
k.z = l
a.p = b
a.s = j
b.t = j
b.v = l
j.p = b
j.s = a
assert k.u.v.z.v.txt == "l"