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

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

k = A("k")
e = B("e")
l = A("l")
n = A("n")
h = B("h")
i = A("i")
b = A("b")

k.o = l
e.p = h
e.w = l
l.o = b
n.o = b
h.p = e
h.w = k
i.o = k
b.o = k
assert b.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

k = A("k")
e = B("e")
l = A("l")
n = A("n")
h = B("h")
i = A("i")
b = A("b")

k.o = l
e.p = h
e.w = l
l.o = b
n.o = b
h.p = e
h.w = k
i.o = k
b.o = k
assert b.o.o.o.o.o.o.o.txt == "k"