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

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

n = A("n")
b = B("b")
c = B("c")

n.o = c
b.t = c
b.u = n
c.t = b
c.u = n
assert n.o.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

n = A("n")
b = B("b")
c = B("c")

n.o = c
b.t = c
b.u = n
c.t = b
c.u = n
assert n.o.u.o.txt == "c"