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

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

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

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

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

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

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

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

l.u = i
l.q = b
l.o = d
i.u = f
i.w = f
e.o = b
b.o = g
j.u = f
j.q = b
j.o = l
d.u = i
d.q = g
d.o = j
f.u = i
f.w = i
g.o = e
assert e.o.o.o.o.o.o.o.o.txt == "g"