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

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

i = A("i")
c = B("c")
a = C("a")
k = D("k")
j = E("j")
m = D("m")
g = E("g")
f = B("f")

i.q = a
c.r = a
c.s = a
c.w = i
c.t = k
c.x = g
a.x = i
k.u = a
k.x = i
k.y = f
k.o = m
j.p = k
m.u = a
m.x = i
m.y = c
m.o = k
g.p = k
f.r = a
f.s = a
f.w = i
f.t = m
f.x = g
assert a.x.q.x.q.x.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

i = A("i")
c = B("c")
a = C("a")
k = D("k")
j = E("j")
m = D("m")
g = E("g")
f = B("f")

i.q = a
c.r = a
c.s = a
c.w = i
c.t = k
c.x = g
a.x = i
k.u = a
k.x = i
k.y = f
k.o = m
j.p = k
m.u = a
m.x = i
m.y = c
m.o = k
g.p = k
f.r = a
f.s = a
f.w = i
f.t = m
f.x = g
assert a.x.q.x.q.x.q.x.txt == "i"