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

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

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

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

g = A("g")
m = B("m")
a = C("a")
j = D("j")

g.s = j
g.x = j
g.y = m
g.z = m
m.x = g
m.p = g
m.u = g
a.s = m
a.u = g
a.r = j
j.o = m
j.u = g
j.w = g
assert g.y.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.y: B = None
        self.x: D = None
        self.z: B = None
        self.txt = txt

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

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

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

g = A("g")
m = B("m")
a = C("a")
j = D("j")

g.s = j
g.x = j
g.y = m
g.z = m
m.x = g
m.p = g
m.u = g
a.s = m
a.u = g
a.r = j
j.o = m
j.u = g
j.w = g
assert g.y.x.s.txt == "j"