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

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

b = A("b")
c = B("c")
j = A("j")
n = B("n")
k = A("k")
l = A("l")
h = A("h")

b.o = k
b.x = j
c.z = n
j.o = k
j.x = l
n.z = c
k.o = j
k.x = h
l.o = h
l.x = k
h.o = l
h.x = l
assert b.x.x.x.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.x: A = None
        self.txt = txt

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

b = A("b")
c = B("c")
j = A("j")
n = B("n")
k = A("k")
l = A("l")
h = A("h")

b.o = k
b.x = j
c.z = n
j.o = k
j.x = l
n.z = c
k.o = j
k.x = h
l.o = h
l.x = k
h.o = l
h.x = l
assert b.x.x.x.o.o.o.o.txt == "k"