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

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

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

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

a.w = b
c.u = i
c.q = e
i.t = h
i.o = a
h.w = a
b.w = a
e.t = h
e.o = b
g.u = e
g.q = i
d.t = b
d.o = b
assert e.t.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

a.w = b
c.u = i
c.q = e
i.t = h
i.o = a
h.w = a
b.w = a
e.t = h
e.o = b
g.u = e
g.q = i
d.t = b
d.o = b
assert e.t.w.w.w.w.w.w.txt == "b"