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

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

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

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.x: A = None
        self.txt = txt

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

f = A("f")
k = B("k")
a = C("a")
m = D("m")
e = E("e")
l = B("l")
i = B("i")

f.q = m
f.z = m
k.z = a
k.q = a
k.y = i
k.s = f
a.t = k
a.z = k
a.q = e
m.s = e
m.x = f
e.r = f
l.z = a
l.q = a
l.y = k
l.s = f
i.z = a
i.q = a
i.y = l
i.s = f
assert f.q.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.x: A = None
        self.txt = txt

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

f = A("f")
k = B("k")
a = C("a")
m = D("m")
e = E("e")
l = B("l")
i = B("i")

f.q = m
f.z = m
k.z = a
k.q = a
k.y = i
k.s = f
a.t = k
a.z = k
a.q = e
m.s = e
m.x = f
e.r = f
l.z = a
l.q = a
l.y = k
l.s = f
i.z = a
i.q = a
i.y = l
i.s = f
assert f.q.s.r.txt == "f"