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

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

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

k.w = c
k.u = e
l.q = k
l.v = k
m.q = k
m.v = f
f.w = i
f.u = e
i.q = f
i.v = f
c.q = e
c.v = k
e.w = b
e.u = f
b.q = f
b.v = f
assert f.w.q.u.u.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: A = None
        self.txt = txt

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

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

k.w = c
k.u = e
l.q = k
l.v = k
m.q = k
m.v = f
f.w = i
f.u = e
i.q = f
i.v = f
c.q = e
c.v = k
e.w = b
e.u = f
b.q = f
b.v = f
assert f.w.q.u.u.w.v.txt == "f"