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

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

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

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

i.p = k
i.q = c
i.s = c
h.v = i
h.y = c
h.w = c
k.p = c
k.v = d
c.v = d
c.y = h
c.w = h
d.p = k
d.q = c
d.s = h
assert i.s.y.w.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: B = None
        self.s: B = None
        self.txt = txt

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

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

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

i.p = k
i.q = c
i.s = c
h.v = i
h.y = c
h.w = c
k.p = c
k.v = d
c.v = d
c.y = h
c.w = h
d.p = k
d.q = c
d.s = h
assert i.s.y.w.v.q.txt == "c"