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

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

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

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

m.v = f
k.w = f
k.x = f
k.p = a
f.q = m
f.t = n
a.v = n
i.w = f
i.x = n
i.p = a
n.q = a
n.t = f
l.w = n
l.x = n
l.p = a
assert a.v.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

m.v = f
k.w = f
k.x = f
k.p = a
f.q = m
f.t = n
a.v = n
i.w = f
i.x = n
i.p = a
n.q = a
n.t = f
l.w = n
l.x = n
l.p = a
assert a.v.q.v.txt == "n"