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

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

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

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

j.t = b
e.w = i
e.y = j
k.p = j
k.x = m
b.t = j
m.p = n
m.x = k
n.t = j
i.w = e
i.y = j
assert b.t.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

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

j.t = b
e.w = i
e.y = j
k.p = j
k.x = m
b.t = j
m.p = n
m.x = k
n.t = j
i.w = e
i.y = j
assert b.t.t.t.t.t.t.t.txt == "j"