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

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

g = A("g")
l = B("l")
m = A("m")
b = A("b")
h = B("h")
n = B("n")

g.v = l
g.u = h
l.z = g
l.u = g
m.v = n
m.u = l
b.v = h
b.u = l
h.z = m
h.u = b
n.z = m
n.u = b
assert m.u.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.txt = txt

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

g = A("g")
l = B("l")
m = A("m")
b = A("b")
h = B("h")
n = B("n")

g.v = l
g.u = h
l.z = g
l.u = g
m.v = n
m.u = l
b.v = h
b.u = l
h.z = m
h.u = b
n.z = m
n.u = b
assert m.u.z.u.z.txt == "m"