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

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

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

h = A("h")
e = B("e")
k = C("k")
a = C("a")
l = A("l")
g = C("g")

h.z = e
h.r = e
h.x = k
e.p = h
e.q = h
e.s = k
k.u = h
k.r = g
k.z = g
a.u = h
a.r = g
a.z = g
l.z = e
l.r = e
l.x = k
g.u = h
g.r = a
g.z = a
assert a.r.z.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: C = None
        self.r: B = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
k = C("k")
a = C("a")
l = A("l")
g = C("g")

h.z = e
h.r = e
h.x = k
e.p = h
e.q = h
e.s = k
k.u = h
k.r = g
k.z = g
a.u = h
a.r = g
a.z = g
l.z = e
l.r = e
l.x = k
g.u = h
g.r = a
g.z = a
assert a.r.z.r.u.txt == "h"