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

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

f = A("f")
a = B("a")
c = A("c")
e = B("e")
d = A("d")
i = A("i")

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

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

f = A("f")
a = B("a")
c = A("c")
e = B("e")
d = A("d")
i = A("i")

f.u = e
a.v = e
a.t = f
c.u = a
e.v = a
e.t = f
d.u = a
i.u = a
assert f.u.v.t.txt == "f"