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

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

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

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

d = A("d")
k = B("k")
b = C("b")
a = D("a")

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

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

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

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

d = A("d")
k = B("k")
b = C("b")
a = D("a")

d.u = k
d.s = a
k.v = d
k.y = d
b.p = a
b.v = a
b.r = a
b.z = d
a.z = k
a.s = b
a.t = b
a.v = d
assert a.v.u.v.s.txt == "a"