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

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

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

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

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

b = A("b")
i = B("i")
k = C("k")
e = D("e")
d = E("d")

b.q = e
i.o = b
i.p = b
i.x = e
i.u = d
k.t = i
k.z = b
k.x = d
e.w = k
e.q = i
e.r = i
d.o = e
d.q = k
d.u = b
assert d.q.x.u.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

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

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

b = A("b")
i = B("i")
k = C("k")
e = D("e")
d = E("d")

b.q = e
i.o = b
i.p = b
i.x = e
i.u = d
k.t = i
k.z = b
k.x = d
e.w = k
e.q = i
e.r = i
d.o = e
d.q = k
d.u = b
assert d.q.x.u.q.r.txt == "i"