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

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

n = A("n")
a = B("a")
c = B("c")
i = A("i")

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

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

n = A("n")
a = B("a")
c = B("c")
i = A("i")

n.t = c
n.w = i
a.u = i
a.v = c
c.u = i
c.v = a
i.t = a
i.w = n
assert n.t.u.w.txt == "n"