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

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

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

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

k.x = h
h.u = l
h.o = c
a.y = g
c.u = a
c.o = h
d.x = c
g.x = c
l.y = k
assert k.x.u.y.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

k.x = h
h.u = l
h.o = c
a.y = g
c.u = a
c.o = h
d.x = c
g.x = c
l.y = k
assert k.x.u.y.x.o.txt == "c"