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

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

c = A("c")
f = B("f")
e = A("e")
k = B("k")

c.q = f
f.o = k
f.w = k
e.q = f
k.o = f
k.w = f
assert f.o.w.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

c = A("c")
f = B("f")
e = A("e")
k = B("k")

c.q = f
f.o = k
f.w = k
e.q = f
k.o = f
k.w = f
assert f.o.w.o.o.txt == "f"