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

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

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

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

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

e = A("e")
f = B("f")
a = C("a")
m = D("m")
i = E("i")
d = B("d")
h = B("h")
b = C("b")

e.r = f
f.x = m
f.q = e
a.w = i
a.s = i
a.t = f
a.x = b
a.z = e
m.y = h
m.q = b
m.r = a
m.w = i
m.x = i
i.t = m
i.s = e
d.x = m
d.q = e
h.x = m
h.q = e
b.w = i
b.s = i
b.t = d
b.x = a
b.z = e
assert e.r.q.r.q.r.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

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

e = A("e")
f = B("f")
a = C("a")
m = D("m")
i = E("i")
d = B("d")
h = B("h")
b = C("b")

e.r = f
f.x = m
f.q = e
a.w = i
a.s = i
a.t = f
a.x = b
a.z = e
m.y = h
m.q = b
m.r = a
m.w = i
m.x = i
i.t = m
i.s = e
d.x = m
d.q = e
h.x = m
h.q = e
b.w = i
b.s = i
b.t = d
b.x = a
b.z = e
assert e.r.q.r.q.r.x.w.txt == "i"