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

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

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

n = A("n")
k = B("k")
j = C("j")
g = C("g")
e = A("e")
d = B("d")

n.u = e
n.q = e
k.s = n
j.t = n
j.y = d
g.t = n
g.y = k
e.u = n
e.q = n
d.s = n
assert e.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: A = None
        self.txt = txt

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

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

n = A("n")
k = B("k")
j = C("j")
g = C("g")
e = A("e")
d = B("d")

n.u = e
n.q = e
k.s = n
j.t = n
j.y = d
g.t = n
g.y = k
e.u = n
e.q = n
d.s = n
assert e.q.q.q.q.q.txt == "n"