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

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

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

i = A("i")
h = B("h")
k = C("k")
c = A("c")
g = C("g")

i.s = g
i.q = h
i.v = h
h.u = c
k.s = h
k.z = g
k.q = g
c.s = k
c.q = h
c.v = h
g.s = h
g.z = k
g.q = k
assert k.s.u.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: B = None
        self.v: B = None
        self.txt = txt

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

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

i = A("i")
h = B("h")
k = C("k")
c = A("c")
g = C("g")

i.s = g
i.q = h
i.v = h
h.u = c
k.s = h
k.z = g
k.q = g
c.s = k
c.q = h
c.v = h
g.s = h
g.z = k
g.q = k
assert k.s.u.s.q.s.txt == "h"