class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

l.v = n
i.q = f
i.s = n
i.w = b
n.q = l
n.w = l
n.s = l
b.q = l
b.w = l
b.s = l
a.q = f
a.s = b
a.w = n
f.q = a
f.s = n
f.w = b
assert f.q.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

l.v = n
i.q = f
i.s = n
i.w = b
n.q = l
n.w = l
n.s = l
b.q = l
b.w = l
b.s = l
a.q = f
a.s = b
a.w = n
f.q = a
f.s = n
f.w = b
assert f.q.q.w.q.txt == "l"