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

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

e = A("e")
b = B("b")
j = A("j")
i = A("i")
k = B("k")
a = A("a")
f = A("f")
d = A("d")
h = A("h")

e.q = b
e.p = b
b.v = k
b.w = f
j.q = b
j.p = k
i.q = k
i.p = b
k.v = b
k.w = j
a.q = k
a.p = b
f.q = b
f.p = k
d.q = k
d.p = b
h.q = b
h.p = k
assert i.p.w.q.v.w.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: B = None
        self.txt = txt

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

e = A("e")
b = B("b")
j = A("j")
i = A("i")
k = B("k")
a = A("a")
f = A("f")
d = A("d")
h = A("h")

e.q = b
e.p = b
b.v = k
b.w = f
j.q = b
j.p = k
i.q = k
i.p = b
k.v = b
k.w = j
a.q = k
a.p = b
f.q = b
f.p = k
d.q = k
d.p = b
h.q = b
h.p = k
assert i.p.w.q.v.w.p.w.p.txt == "k"