class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.r: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: B = None
        self.o: D = None
        self.x: C = None
        self.txt = txt

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

m.p = n
m.r = n
g.w = j
j.x = k
j.q = m
j.w = g
j.u = g
k.z = j
n.z = m
n.u = g
n.o = k
n.x = j
assert k.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.r: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: B = None
        self.o: D = None
        self.x: C = None
        self.txt = txt

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

m.p = n
m.r = n
g.w = j
j.x = k
j.q = m
j.w = g
j.u = g
k.z = j
n.z = m
n.u = g
n.o = k
n.x = j
assert k.z.x.z.txt == "j"