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

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

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

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

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

e = A("e")
i = B("i")
g = C("g")
n = D("n")
b = E("b")

e.q = i
i.r = g
g.z = n
g.q = e
g.t = e
g.y = b
g.u = i
n.v = b
n.u = e
b.x = e
b.t = e
b.v = g
assert n.u.q.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

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

e = A("e")
i = B("i")
g = C("g")
n = D("n")
b = E("b")

e.q = i
i.r = g
g.z = n
g.q = e
g.t = e
g.y = b
g.u = i
n.v = b
n.u = e
b.x = e
b.t = e
b.v = g
assert n.u.q.r.u.txt == "i"