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

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

e = A("e")
b = B("b")
j = B("j")
i = A("i")
c = A("c")

e.w = c
e.o = c
b.q = i
j.q = i
i.w = e
i.o = c
c.w = e
c.o = e
assert e.w.w.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: A = None
        self.txt = txt

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

e = A("e")
b = B("b")
j = B("j")
i = A("i")
c = A("c")

e.w = c
e.o = c
b.q = i
j.q = i
i.w = e
i.o = c
c.w = e
c.o = e
assert e.w.w.o.o.txt == "e"