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

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

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

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

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

a = A("a")
c = B("c")
f = C("f")
i = D("i")
b = E("b")
m = C("m")

a.u = i
a.t = c
a.q = c
a.p = b
c.q = a
f.r = b
f.x = c
f.q = a
f.z = a
i.o = f
b.z = i
b.r = i
m.r = b
m.x = c
m.q = a
m.z = a
assert a.u.o.z.q.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.t: B = None
        self.p: E = None
        self.q: B = None
        self.txt = txt

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

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

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

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

a = A("a")
c = B("c")
f = C("f")
i = D("i")
b = E("b")
m = C("m")

a.u = i
a.t = c
a.q = c
a.p = b
c.q = a
f.r = b
f.x = c
f.q = a
f.z = a
i.o = f
b.z = i
b.r = i
m.r = b
m.x = c
m.q = a
m.z = a
assert a.u.o.z.q.q.p.txt == "b"