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.w: B = None
        self.y: A = None
        self.txt = txt

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

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

k.o = m
k.p = i
h.w = m
h.y = i
g.q = a
a.q = g
m.w = h
m.y = k
j.q = g
i.o = h
i.p = k
b.q = g
assert i.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.w: B = None
        self.y: A = None
        self.txt = txt

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

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

k.o = m
k.p = i
h.w = m
h.y = i
g.q = a
a.q = g
m.w = h
m.y = k
j.q = g
i.o = h
i.p = k
b.q = g
assert i.o.w.w.txt == "h"