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

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

m = A("m")
c = B("c")
j = A("j")
f = A("f")

m.u = j
m.o = j
c.v = j
j.u = f
j.o = m
f.u = j
f.o = m
assert m.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: A = None
        self.txt = txt

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

m = A("m")
c = B("c")
j = A("j")
f = A("f")

m.u = j
m.o = j
c.v = j
j.u = f
j.o = m
f.u = j
f.o = m
assert m.u.u.u.txt == "j"