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

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

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

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

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

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

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

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

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

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

e.q = k
k.z = j
k.p = j
k.o = e
k.s = m
j.y = k
j.s = k
j.t = e
j.z = m
m.p = k
assert m.p.s.p.s.txt == "m"