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

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

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

l.q = f
f.o = d
c.o = d
a.q = c
d.q = c
assert c.o.q.o.q.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: A = None
        self.txt = txt

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

l.q = f
f.o = d
c.o = d
a.q = c
d.q = c
assert c.o.q.o.q.o.txt == "d"