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

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

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

f = A("f")
j = B("j")
h = C("h")
l = C("l")
g = B("g")

f.o = j
f.z = j
j.r = g
j.s = l
h.s = g
h.y = g
h.w = f
l.s = j
l.w = f
l.y = g
g.r = j
g.s = h
assert g.s.w.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: B = None
        self.txt = txt

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

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

f = A("f")
j = B("j")
h = C("h")
l = C("l")
g = B("g")

f.o = j
f.z = j
j.r = g
j.s = l
h.s = g
h.y = g
h.w = f
l.s = j
l.w = f
l.y = g
g.r = j
g.s = h
assert g.s.w.o.s.txt == "l"