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

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

i = A("i")
m = B("m")
k = B("k")
n = B("n")
c = A("c")

i.x = n
i.v = n
m.u = n
m.o = c
k.u = m
k.o = c
n.u = m
n.o = c
c.x = m
c.v = m
assert k.o.v.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.v: B = None
        self.txt = txt

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

i = A("i")
m = B("m")
k = B("k")
n = B("n")
c = A("c")

i.x = n
i.v = n
m.u = n
m.o = c
k.u = m
k.o = c
n.u = m
n.o = c
c.x = m
c.v = m
assert k.o.v.u.o.txt == "c"