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

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

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

j = A("j")
a = B("a")
c = C("c")
h = C("h")

j.s = a
a.y = c
a.s = h
c.o = a
h.o = a
assert j.s.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

j = A("j")
a = B("a")
c = C("c")
h = C("h")

j.s = a
a.y = c
a.s = h
c.o = a
h.o = a
assert j.s.s.o.txt == "a"