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

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

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

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

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

f = A("f")
d = B("d")
c = C("c")
k = D("k")
m = E("m")
a = B("a")

f.q = a
d.y = a
d.z = k
c.w = m
c.o = d
c.u = f
c.x = k
c.r = k
k.o = a
m.y = a
m.x = c
a.y = d
a.z = k
assert f.q.z.o.y.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

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

f = A("f")
d = B("d")
c = C("c")
k = D("k")
m = E("m")
a = B("a")

f.q = a
d.y = a
d.z = k
c.w = m
c.o = d
c.u = f
c.x = k
c.r = k
k.o = a
m.y = a
m.x = c
a.y = d
a.z = k
assert f.q.z.o.y.z.o.txt == "a"