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

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

e = A("e")
i = B("i")
b = A("b")
h = B("h")
m = B("m")
f = B("f")
j = B("j")

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

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

e = A("e")
i = B("i")
b = A("b")
h = B("h")
m = B("m")
f = B("f")
j = B("j")

e.x = h
i.w = m
i.q = j
b.x = m
h.w = f
h.q = i
m.w = j
m.q = i
f.w = m
f.q = h
j.w = f
j.q = i
assert j.q.q.q.w.w.q.w.txt == "m"