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

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: C = None
        self.txt = txt

g = A("g")
c = B("c")
f = C("f")
m = D("m")

g.s = m
g.u = f
c.w = g
c.t = g
c.r = g
c.y = m
f.t = g
f.z = g
m.w = c
m.o = f
assert g.u.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.u: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: C = None
        self.txt = txt

g = A("g")
c = B("c")
f = C("f")
m = D("m")

g.s = m
g.u = f
c.w = g
c.t = g
c.r = g
c.y = m
f.t = g
f.z = g
m.w = c
m.o = f
assert g.u.z.s.txt == "m"