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

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

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

c = A("c")
n = B("n")
g = C("g")
f = C("f")
i = A("i")
e = A("e")
a = C("a")
d = B("d")

c.s = e
c.r = a
c.q = d
n.v = f
g.w = f
g.v = f
f.w = g
f.v = g
i.s = c
i.r = a
i.q = d
e.s = i
e.r = f
e.q = n
a.w = g
a.v = f
d.v = f
assert c.s.r.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: C = None
        self.q: B = None
        self.txt = txt

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

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

c = A("c")
n = B("n")
g = C("g")
f = C("f")
i = A("i")
e = A("e")
a = C("a")
d = B("d")

c.s = e
c.r = a
c.q = d
n.v = f
g.w = f
g.v = f
f.w = g
f.v = g
i.s = c
i.r = a
i.q = d
e.s = i
e.r = f
e.q = n
a.w = g
a.v = f
d.v = f
assert c.s.r.v.v.txt == "f"