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

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

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

b = A("b")
d = B("d")
a = C("a")
h = C("h")
n = A("n")
c = B("c")
f = C("f")
i = C("i")

b.q = c
b.z = n
d.v = n
a.y = n
h.y = n
n.q = d
n.z = b
c.v = b
f.y = n
i.y = b
assert f.y.q.v.z.q.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: A = None
        self.txt = txt

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

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

b = A("b")
d = B("d")
a = C("a")
h = C("h")
n = A("n")
c = B("c")
f = C("f")
i = C("i")

b.q = c
b.z = n
d.v = n
a.y = n
h.y = n
n.q = d
n.z = b
c.v = b
f.y = n
i.y = b
assert f.y.q.v.z.q.v.q.txt == "c"