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

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

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

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

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

j = A("j")
a = B("a")
k = C("k")
d = D("d")
n = E("n")
g = D("g")

j.x = k
j.o = k
j.u = k
j.q = d
a.r = j
a.u = j
a.q = n
a.z = n
a.w = d
k.r = a
k.s = a
k.x = n
k.z = j
d.q = g
n.t = g
n.o = k
n.w = a
g.q = d
assert d.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.o: C = None
        self.q: D = None
        self.u: C = None
        self.txt = txt

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

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

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

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

j = A("j")
a = B("a")
k = C("k")
d = D("d")
n = E("n")
g = D("g")

j.x = k
j.o = k
j.u = k
j.q = d
a.r = j
a.u = j
a.q = n
a.z = n
a.w = d
k.r = a
k.s = a
k.x = n
k.z = j
d.q = g
n.t = g
n.o = k
n.w = a
g.q = d
assert d.q.q.q.q.q.q.txt == "d"