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

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

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

h = A("h")
d = B("d")
g = C("g")
k = A("k")
m = B("m")
a = A("a")

h.q = g
h.o = g
d.s = g
d.p = m
d.r = m
g.w = a
g.q = a
g.o = k
k.q = g
k.o = g
m.s = g
m.p = d
m.r = d
a.q = g
a.o = g
assert a.q.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: C = None
        self.txt = txt

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

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

h = A("h")
d = B("d")
g = C("g")
k = A("k")
m = B("m")
a = A("a")

h.q = g
h.o = g
d.s = g
d.p = m
d.r = m
g.w = a
g.q = a
g.o = k
k.q = g
k.o = g
m.s = g
m.p = d
m.r = d
a.q = g
a.o = g
assert a.q.q.o.txt == "g"