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

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

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

h = A("h")
l = B("l")
g = C("g")
a = A("a")
n = C("n")

h.p = n
h.x = l
l.t = n
l.y = n
g.t = a
g.r = h
g.u = l
a.p = g
a.x = l
n.t = a
n.r = a
n.u = l
assert h.x.y.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: B = None
        self.txt = txt

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

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

h = A("h")
l = B("l")
g = C("g")
a = A("a")
n = C("n")

h.p = n
h.x = l
l.t = n
l.y = n
g.t = a
g.r = h
g.u = l
a.p = g
a.x = l
n.t = a
n.r = a
n.u = l
assert h.x.y.t.x.txt == "l"