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

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

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

n = A("n")
i = B("i")
a = C("a")
c = C("c")
l = B("l")
h = C("h")

n.x = h
i.y = h
i.u = n
i.o = a
a.o = l
c.o = i
l.y = c
l.u = n
l.o = a
h.o = l
assert n.x.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

n = A("n")
i = B("i")
a = C("a")
c = C("c")
l = B("l")
h = C("h")

n.x = h
i.y = h
i.u = n
i.o = a
a.o = l
c.o = i
l.y = c
l.u = n
l.o = a
h.o = l
assert n.x.o.y.txt == "c"