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

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

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

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

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

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

i.t = f
f.v = k
d.v = f
k.v = d
assert i.t.v.v.txt == "d"