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

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

a = A("a")
g = B("g")
k = A("k")
l = A("l")
c = B("c")
e = B("e")
j = A("j")
d = A("d")
i = A("i")
h = B("h")

a.o = e
g.x = l
k.o = h
l.o = h
c.x = l
e.x = j
j.o = g
d.o = h
i.o = g
h.x = i
assert k.o.x.o.x.o.x.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

a = A("a")
g = B("g")
k = A("k")
l = A("l")
c = B("c")
e = B("e")
j = A("j")
d = A("d")
i = A("i")
h = B("h")

a.o = e
g.x = l
k.o = h
l.o = h
c.x = l
e.x = j
j.o = g
d.o = h
i.o = g
h.x = i
assert k.o.x.o.x.o.x.o.x.o.txt == "h"