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

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

n = A("n")
b = B("b")
d = B("d")
h = B("h")
m = A("m")
l = A("l")
c = A("c")
j = A("j")
g = A("g")
a = A("a")

n.v = c
n.x = j
b.y = h
b.v = d
d.y = b
d.v = h
h.y = d
h.v = b
m.v = c
m.x = a
l.v = g
l.x = m
c.v = n
c.x = l
j.v = g
j.x = g
g.v = a
g.x = n
a.v = n
a.x = l
assert c.x.v.v.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.x: A = None
        self.txt = txt

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

n = A("n")
b = B("b")
d = B("d")
h = B("h")
m = A("m")
l = A("l")
c = A("c")
j = A("j")
g = A("g")
a = A("a")

n.v = c
n.x = j
b.y = h
b.v = d
d.y = b
d.v = h
h.y = d
h.v = b
m.v = c
m.x = a
l.v = g
l.x = m
c.v = n
c.x = l
j.v = g
j.x = g
g.v = a
g.x = n
a.v = n
a.x = l
assert c.x.v.v.v.x.txt == "j"