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

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

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

j = A("j")
b = B("b")
f = C("f")
g = A("g")
a = C("a")
i = A("i")
d = B("d")

j.y = f
j.o = d
b.o = d
f.w = b
f.o = b
f.q = d
g.y = f
g.o = b
a.w = d
a.q = d
a.o = b
i.y = f
i.o = d
d.o = b
assert i.y.w.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.o: B = None
        self.txt = txt

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

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

j = A("j")
b = B("b")
f = C("f")
g = A("g")
a = C("a")
i = A("i")
d = B("d")

j.y = f
j.o = d
b.o = d
f.w = b
f.o = b
f.q = d
g.y = f
g.o = b
a.w = d
a.q = d
a.o = b
i.y = f
i.o = d
d.o = b
assert i.y.w.o.o.txt == "b"