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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: D = None
        self.s: A = None
        self.u: A = None
        self.txt = txt

i = A("i")
l = B("l")
j = C("j")
e = D("e")
m = E("m")

i.u = j
l.q = e
l.v = e
l.z = i
j.p = l
e.u = m
e.r = l
e.t = i
e.w = i
m.z = j
m.v = e
m.s = i
m.u = i
assert i.u.p.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: D = None
        self.s: A = None
        self.u: A = None
        self.txt = txt

i = A("i")
l = B("l")
j = C("j")
e = D("e")
m = E("m")

i.u = j
l.q = e
l.v = e
l.z = i
j.p = l
e.u = m
e.r = l
e.t = i
e.w = i
m.z = j
m.v = e
m.s = i
m.u = i
assert i.u.p.z.u.txt == "j"