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

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

f = A("f")
l = B("l")
a = A("a")
b = B("b")
d = B("d")
c = B("c")
i = B("i")

f.s = a
f.q = a
l.t = f
a.s = f
a.q = f
b.t = a
d.t = f
c.t = f
i.t = f
assert d.t.s.s.s.q.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: A = None
        self.txt = txt

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

f = A("f")
l = B("l")
a = A("a")
b = B("b")
d = B("d")
c = B("c")
i = B("i")

f.s = a
f.q = a
l.t = f
a.s = f
a.q = f
b.t = a
d.t = f
c.t = f
i.t = f
assert d.t.s.s.s.q.q.s.txt == "f"