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

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

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

i = A("i")
d = B("d")
h = C("h")
f = A("f")
m = B("m")
c = A("c")

i.v = m
i.s = m
i.x = h
d.q = h
h.t = d
h.v = c
f.v = d
f.s = d
f.x = h
m.q = h
c.v = m
c.s = m
c.x = h
assert d.q.t.q.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.s: B = None
        self.x: C = None
        self.txt = txt

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

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

i = A("i")
d = B("d")
h = C("h")
f = A("f")
m = B("m")
c = A("c")

i.v = m
i.s = m
i.x = h
d.q = h
h.t = d
h.v = c
f.v = d
f.s = d
f.x = h
m.q = h
c.v = m
c.s = m
c.x = h
assert d.q.t.q.v.s.txt == "m"