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

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

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

h.u = g
h.x = j
e.v = g
e.o = b
n.u = h
n.x = j
c.v = b
c.o = d
b.u = d
b.x = j
d.u = b
d.x = c
a.v = g
a.o = g
g.u = d
g.x = c
j.v = b
j.o = g
assert d.x.o.u.u.x.v.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.x: B = None
        self.txt = txt

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

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

h.u = g
h.x = j
e.v = g
e.o = b
n.u = h
n.x = j
c.v = b
c.o = d
b.u = d
b.x = j
d.u = b
d.x = c
a.v = g
a.o = g
g.u = d
g.x = c
j.v = b
j.o = g
assert d.x.o.u.u.x.v.x.o.txt == "g"