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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.v: E = None
        self.q: A = None
        self.txt = txt

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

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

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

d.q = l
d.o = n
d.r = n
m.u = c
m.w = i
m.x = i
m.o = l
m.p = l
f.p = l
f.v = l
f.q = n
b.x = l
l.r = b
i.u = f
i.w = m
i.x = m
i.o = l
i.p = l
a.p = l
a.v = l
a.q = n
c.p = l
c.v = l
c.q = n
n.q = l
n.o = d
n.r = d
assert i.w.o.r.x.r.x.r.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.o: A = None
        self.r: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.v: E = None
        self.q: A = None
        self.txt = txt

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

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

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

d.q = l
d.o = n
d.r = n
m.u = c
m.w = i
m.x = i
m.o = l
m.p = l
f.p = l
f.v = l
f.q = n
b.x = l
l.r = b
i.u = f
i.w = m
i.x = m
i.o = l
i.p = l
a.p = l
a.v = l
a.q = n
c.p = l
c.v = l
c.q = n
n.q = l
n.o = d
n.r = d
assert i.w.o.r.x.r.x.r.x.r.txt == "b"