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

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

f = A("f")
j = B("j")
c = B("c")
d = B("d")
m = B("m")
i = B("i")
b = A("b")
k = A("k")
a = B("a")

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

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

f = A("f")
j = B("j")
c = B("c")
d = B("d")
m = B("m")
i = B("i")
b = A("b")
k = A("k")
a = B("a")

f.q = k
f.w = b
j.x = f
j.o = f
c.x = b
c.o = f
d.x = f
d.o = f
m.x = f
m.o = b
i.x = b
i.o = f
b.q = k
b.w = k
k.q = b
k.w = b
a.x = k
a.o = b
assert m.o.q.q.q.q.w.txt == "k"