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

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

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

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

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

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

k.y = j
a.q = e
a.w = k
d.q = b
d.w = k
e.q = a
e.w = k
j.y = k
b.q = a
b.w = k
i.q = e
i.w = k
assert e.w.y.y.y.txt == "j"