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

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

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

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

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

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

e.o = h
e.u = g
b.x = c
b.o = e
g.x = b
g.o = k
k.o = e
k.u = g
c.x = g
c.o = h
h.o = e
h.u = g
m.o = k
m.u = c
assert g.o.o.u.o.txt == "k"