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

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: A = None
        self.t: E = None
        self.r: C = None
        self.p: B = None
        self.txt = txt

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

j = A("j")
i = B("i")
g = C("g")
n = D("n")
l = E("l")
e = C("e")
k = C("k")

j.q = g
i.s = g
g.t = n
g.x = j
n.y = i
n.p = i
n.v = j
n.t = l
n.r = g
l.x = k
e.t = n
e.x = j
k.t = n
k.x = j
assert k.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.s: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: A = None
        self.t: E = None
        self.r: C = None
        self.p: B = None
        self.txt = txt

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

j = A("j")
i = B("i")
g = C("g")
n = D("n")
l = E("l")
e = C("e")
k = C("k")

j.q = g
i.s = g
g.t = n
g.x = j
n.y = i
n.p = i
n.v = j
n.t = l
n.r = g
l.x = k
e.t = n
e.x = j
k.t = n
k.x = j
assert k.x.q.x.q.x.txt == "j"