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

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

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

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

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

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

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

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

m.w = b
m.q = b
g.y = m
g.w = b
k.r = f
k.o = f
k.p = d
e.y = d
e.w = k
f.r = b
f.p = d
f.o = k
h.y = m
h.w = f
a.y = m
a.w = k
d.w = k
d.q = b
b.r = k
b.p = m
b.o = f
assert m.q.p.w.txt == "b"