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

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

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

n = A("n")
h = B("h")
f = C("f")
b = C("b")
d = B("d")

n.z = b
n.q = h
n.r = f
h.o = b
h.p = d
h.s = n
f.y = d
f.v = d
b.y = d
b.v = d
d.o = f
d.p = h
d.s = n
assert h.s.r.y.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: B = None
        self.r: C = None
        self.txt = txt

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

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

n = A("n")
h = B("h")
f = C("f")
b = C("b")
d = B("d")

n.z = b
n.q = h
n.r = f
h.o = b
h.p = d
h.s = n
f.y = d
f.v = d
b.y = d
b.v = d
d.o = f
d.p = h
d.s = n
assert h.s.r.y.p.p.txt == "d"