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

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

m = A("m")
i = B("i")
l = B("l")
j = A("j")
b = B("b")
n = B("n")

m.u = j
m.v = j
i.x = l
l.x = n
j.u = m
j.v = m
b.x = i
n.x = i
assert b.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: A = None
        self.txt = txt

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

m = A("m")
i = B("i")
l = B("l")
j = A("j")
b = B("b")
n = B("n")

m.u = j
m.v = j
i.x = l
l.x = n
j.u = m
j.v = m
b.x = i
n.x = i
assert b.x.x.x.x.x.x.txt == "n"