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

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

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

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

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

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

i.u = f
m.t = k
m.v = i
f.u = i
k.t = m
k.v = f
assert f.u.u.u.u.txt == "f"