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

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

f = A("f")
e = B("e")
a = A("a")
n = B("n")
h = A("h")
k = A("k")

f.t = k
e.z = n
e.s = a
a.t = h
n.z = e
n.s = f
h.t = k
k.t = a
assert h.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.z: B = None
        self.s: A = None
        self.txt = txt

f = A("f")
e = B("e")
a = A("a")
n = B("n")
h = A("h")
k = A("k")

f.t = k
e.z = n
e.s = a
a.t = h
n.z = e
n.s = f
h.t = k
k.t = a
assert h.t.t.t.t.t.txt == "a"