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

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

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

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

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

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

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

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

k.s = g
k.o = g
k.r = e
g.s = e
g.r = h
g.t = l
e.p = l
e.u = l
h.p = l
h.u = k
l.s = g
l.o = g
l.r = h
assert k.o.r.u.o.txt == "g"