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

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

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

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

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

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

f.u = k
f.v = k
d.t = e
e.t = d
k.u = f
k.v = f
assert f.u.v.v.txt == "k"