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

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

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

k = A("k")
i = B("i")
h = C("h")
e = A("e")
d = A("d")
c = C("c")
f = B("f")

k.u = c
i.s = d
h.x = k
h.o = c
h.u = e
e.u = h
d.u = h
c.x = e
c.o = h
c.u = d
f.s = k
assert i.s.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

k = A("k")
i = B("i")
h = C("h")
e = A("e")
d = A("d")
c = C("c")
f = B("f")

k.u = c
i.s = d
h.x = k
h.o = c
h.u = e
e.u = h
d.u = h
c.x = e
c.o = h
c.u = d
f.s = k
assert i.s.u.x.u.txt == "c"