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

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

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

j = A("j")
i = B("i")
l = C("l")
h = A("h")
c = C("c")

j.s = c
j.q = l
i.x = c
i.s = c
i.o = h
l.u = c
l.s = i
l.p = i
h.s = c
h.q = l
c.u = l
c.s = i
c.p = i
assert h.s.p.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: C = None
        self.txt = txt

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

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

j = A("j")
i = B("i")
l = C("l")
h = A("h")
c = C("c")

j.s = c
j.q = l
i.x = c
i.s = c
i.o = h
l.u = c
l.s = i
l.p = i
h.s = c
h.q = l
c.u = l
c.s = i
c.p = i
assert h.s.p.x.s.txt == "i"