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

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

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

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

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

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

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

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

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

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

m.z = j
m.p = g
m.o = g
m.s = k
j.y = g
j.o = g
j.r = g
g.z = k
k.p = j
k.t = g
assert j.o.z.t.z.txt == "k"