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

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

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

j = A("j")
b = B("b")
g = C("g")
i = A("i")
h = C("h")
m = B("m")
a = A("a")
f = B("f")
c = A("c")
d = B("d")

j.o = m
j.p = a
b.r = h
b.w = d
g.x = m
i.o = d
i.p = a
h.x = b
m.r = g
m.w = d
a.o = d
a.p = j
f.r = g
f.w = d
c.o = m
c.p = i
d.r = h
d.w = m
assert j.o.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: A = None
        self.txt = txt

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

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

j = A("j")
b = B("b")
g = C("g")
i = A("i")
h = C("h")
m = B("m")
a = A("a")
f = B("f")
c = A("c")
d = B("d")

j.o = m
j.p = a
b.r = h
b.w = d
g.x = m
i.o = d
i.p = a
h.x = b
m.r = g
m.w = d
a.o = d
a.p = j
f.r = g
f.w = d
c.o = m
c.p = i
d.r = h
d.w = m
assert j.o.w.w.txt == "m"