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

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

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

i = A("i")
l = B("l")
b = C("b")
a = C("a")
e = B("e")
d = A("d")
g = B("g")
h = A("h")

i.q = h
i.w = a
l.s = b
b.p = g
b.o = a
a.p = g
a.o = b
e.s = a
d.q = h
d.w = b
g.s = a
h.q = i
h.w = b
assert l.s.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: C = None
        self.txt = txt

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

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

i = A("i")
l = B("l")
b = C("b")
a = C("a")
e = B("e")
d = A("d")
g = B("g")
h = A("h")

i.q = h
i.w = a
l.s = b
b.p = g
b.o = a
a.p = g
a.o = b
e.s = a
d.q = h
d.w = b
g.s = a
h.q = i
h.w = b
assert l.s.o.o.txt == "b"