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

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

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

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

i.r = n
i.u = n
i.q = g
n.u = b
g.u = k
b.r = n
b.u = n
b.q = k
k.u = g
j.r = n
j.u = n
j.q = g
d.r = n
d.u = n
d.q = g
assert k.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: C = None
        self.u: B = None
        self.txt = txt

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

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

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

i.r = n
i.u = n
i.q = g
n.u = b
g.u = k
b.r = n
b.u = n
b.q = k
k.u = g
j.r = n
j.u = n
j.q = g
d.r = n
d.u = n
d.q = g
assert k.u.u.u.u.u.u.txt == "k"