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

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

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

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

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

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

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

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

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

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

g.x = m
g.y = a
g.t = j
g.s = j
a.z = g
k.z = j
k.w = j
k.y = m
k.s = g
j.o = k
m.z = j
m.w = j
m.y = k
m.s = g
assert k.z.o.y.txt == "m"