class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: B = None
        self.r: D = None
        self.y: D = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
c = C("c")
i = D("i")

f.x = c
f.z = b
f.r = i
f.y = i
b.u = c
c.r = f
c.q = i
i.r = b
i.u = f
assert f.r.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: B = None
        self.r: D = None
        self.y: D = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
c = C("c")
i = D("i")

f.x = c
f.z = b
f.r = i
f.y = i
b.u = c
c.r = f
c.q = i
i.r = b
i.u = f
assert f.r.u.y.txt == "i"