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

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

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

d = A("d")
k = B("k")
c = C("c")
h = B("h")
g = B("g")
n = C("n")
e = C("e")
f = C("f")

d.x = k
d.s = k
k.y = g
k.q = c
k.x = h
c.w = h
c.v = d
c.z = e
h.y = k
h.q = c
h.x = g
g.y = k
g.x = k
g.q = f
n.w = h
n.v = d
n.z = f
e.w = g
e.v = d
e.z = n
f.w = h
f.v = d
f.z = n
assert g.y.y.q.v.s.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: B = None
        self.txt = txt

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

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

d = A("d")
k = B("k")
c = C("c")
h = B("h")
g = B("g")
n = C("n")
e = C("e")
f = C("f")

d.x = k
d.s = k
k.y = g
k.q = c
k.x = h
c.w = h
c.v = d
c.z = e
h.y = k
h.q = c
h.x = g
g.y = k
g.x = k
g.q = f
n.w = h
n.v = d
n.z = f
e.w = g
e.v = d
e.z = n
f.w = h
f.v = d
f.z = n
assert g.y.y.q.v.s.q.w.q.txt == "c"