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

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

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

d = A("d")
h = B("h")
a = C("a")
n = B("n")
g = C("g")
b = C("b")
e = C("e")

d.r = h
h.z = g
h.q = g
h.s = n
a.o = h
a.p = d
a.u = n
n.z = a
n.q = b
n.s = h
g.o = n
g.u = n
g.p = d
b.o = n
b.u = n
b.p = d
e.o = h
e.u = h
e.p = d
assert b.p.r.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
a = C("a")
n = B("n")
g = C("g")
b = C("b")
e = C("e")

d.r = h
h.z = g
h.q = g
h.s = n
a.o = h
a.p = d
a.u = n
n.z = a
n.q = b
n.s = h
g.o = n
g.u = n
g.p = d
b.o = n
b.u = n
b.p = d
e.o = h
e.u = h
e.p = d
assert b.p.r.s.z.txt == "a"