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

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

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

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

k = A("k")
j = B("j")
c = C("c")
e = D("e")

k.u = c
k.w = c
k.r = e
j.u = k
j.s = c
c.y = k
e.v = k
e.z = j
e.s = j
assert c.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.r: D = None
        self.w: C = None
        self.txt = txt

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

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

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

k = A("k")
j = B("j")
c = C("c")
e = D("e")

k.u = c
k.w = c
k.r = e
j.u = k
j.s = c
c.y = k
e.v = k
e.z = j
e.s = j
assert c.y.w.y.txt == "k"