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

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

i = A("i")
f = B("f")
k = A("k")
a = A("a")

i.t = f
f.p = k
k.t = f
a.t = f
assert a.t.p.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

i = A("i")
f = B("f")
k = A("k")
a = A("a")

i.t = f
f.p = k
k.t = f
a.t = f
assert a.t.p.t.p.txt == "k"