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

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

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

l = A("l")
j = B("j")
g = C("g")
d = A("d")

l.y = d
l.t = d
l.s = g
j.w = g
g.o = l
d.y = l
d.t = l
d.s = g
assert l.s.o.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.s: C = None
        self.t: A = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
g = C("g")
d = A("d")

l.y = d
l.t = d
l.s = g
j.w = g
g.o = l
d.y = l
d.t = l
d.s = g
assert l.s.o.s.o.txt == "l"