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

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

l = A("l")
c = B("c")
n = A("n")
h = B("h")
g = A("g")
i = A("i")
m = A("m")

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

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

l = A("l")
c = B("c")
n = A("n")
h = B("h")
g = A("g")
i = A("i")
m = A("m")

l.x = n
l.v = h
c.u = m
c.s = n
n.x = g
n.v = h
h.u = i
h.s = g
g.x = i
g.v = h
i.x = l
i.v = c
m.x = l
m.v = h
assert h.u.v.u.v.txt == "h"