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

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

h = A("h")
m = B("m")
b = A("b")
l = A("l")
e = A("e")
g = B("g")
k = A("k")

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

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

h = A("h")
m = B("m")
b = A("b")
l = A("l")
e = A("e")
g = B("g")
k = A("k")

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