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

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

k = A("k")
c = B("c")
i = B("i")
m = A("m")
f = B("f")
b = B("b")
h = A("h")

k.q = c
k.x = i
c.o = h
c.w = i
i.o = h
i.w = c
m.q = b
m.x = c
f.o = k
f.w = c
b.o = m
b.w = c
h.q = i
h.x = i
assert m.q.o.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: B = None
        self.txt = txt

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

k = A("k")
c = B("c")
i = B("i")
m = A("m")
f = B("f")
b = B("b")
h = A("h")

k.q = c
k.x = i
c.o = h
c.w = i
i.o = h
i.w = c
m.q = b
m.x = c
f.o = k
f.w = c
b.o = m
b.w = c
h.q = i
h.x = i
assert m.q.o.q.w.w.txt == "i"