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

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

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

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

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

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

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

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

b.v = k
b.y = k
b.p = m
n.y = k
n.t = f
m.q = a
i.y = k
i.t = f
f.q = m
k.v = b
k.y = b
k.p = f
a.q = f
assert i.t.q.q.q.txt == "f"