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

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

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

b = A("b")
k = B("k")
c = C("c")
j = B("j")
m = A("m")
h = C("h")
a = C("a")
f = B("f")

b.w = m
b.q = m
b.o = m
k.w = c
c.q = a
c.v = a
j.w = a
m.w = b
m.q = b
m.o = b
h.q = a
h.v = a
a.q = h
a.v = c
f.w = c
assert c.v.v.q.v.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: A = None
        self.o: A = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
c = C("c")
j = B("j")
m = A("m")
h = C("h")
a = C("a")
f = B("f")

b.w = m
b.q = m
b.o = m
k.w = c
c.q = a
c.v = a
j.w = a
m.w = b
m.q = b
m.o = b
h.q = a
h.v = a
a.q = h
a.v = c
f.w = c
assert c.v.v.q.v.q.q.q.txt == "a"