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

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

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

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

n.u = b
l.t = j
b.p = j
k.t = n
g.p = i
e.t = n
i.u = b
j.u = b
assert b.p.u.p.u.p.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

n.u = b
l.t = j
b.p = j
k.t = n
g.p = i
e.t = n
i.u = b
j.u = b
assert b.p.u.p.u.p.u.p.txt == "j"