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

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

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

l = A("l")
a = B("a")
n = C("n")
b = B("b")
f = B("f")

l.q = b
a.y = l
a.w = l
a.q = n
n.y = l
n.w = a
b.y = l
b.w = l
b.q = n
f.y = l
f.w = l
f.q = n
assert n.y.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

l = A("l")
a = B("a")
n = C("n")
b = B("b")
f = B("f")

l.q = b
a.y = l
a.w = l
a.q = n
n.y = l
n.w = a
b.y = l
b.w = l
b.q = n
f.y = l
f.w = l
f.q = n
assert n.y.q.q.txt == "n"