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

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

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

a = A("a")
k = B("k")
j = C("j")
i = A("i")
g = B("g")
c = C("c")
h = C("h")

a.w = i
a.x = i
k.o = j
k.x = j
j.u = a
j.q = k
i.w = a
i.x = a
g.o = j
g.x = c
c.u = i
c.q = k
h.u = a
h.q = k
assert g.o.q.x.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: A = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
j = C("j")
i = A("i")
g = B("g")
c = C("c")
h = C("h")

a.w = i
a.x = i
k.o = j
k.x = j
j.u = a
j.q = k
i.w = a
i.x = a
g.o = j
g.x = c
c.u = i
c.q = k
h.u = a
h.q = k
assert g.o.q.x.u.x.txt == "i"