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

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

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

h = A("h")
l = B("l")
i = C("i")
b = A("b")
n = B("n")
k = A("k")

h.t = k
h.w = i
l.w = n
i.t = l
b.t = k
b.w = i
n.w = l
k.t = h
k.w = i
assert i.t.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.w: C = None
        self.txt = txt

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

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

h = A("h")
l = B("l")
i = C("i")
b = A("b")
n = B("n")
k = A("k")

h.t = k
h.w = i
l.w = n
i.t = l
b.t = k
b.w = i
n.w = l
k.t = h
k.w = i
assert i.t.w.w.w.w.w.txt == "n"