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.w: A = None
        self.txt = txt

l = A("l")
e = B("e")
k = A("k")
b = B("b")
j = A("j")

l.o = j
l.x = k
e.w = l
k.o = j
k.x = l
b.w = k
j.o = k
j.x = l
assert j.o.x.o.x.x.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.w: A = None
        self.txt = txt

l = A("l")
e = B("e")
k = A("k")
b = B("b")
j = A("j")

l.o = j
l.x = k
e.w = l
k.o = j
k.x = l
b.w = k
j.o = k
j.x = l
assert j.o.x.o.x.x.txt == "k"