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

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

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

k = A("k")
b = B("b")
m = C("m")
j = C("j")
n = A("n")
h = C("h")
d = A("d")

k.x = j
k.o = h
b.t = k
m.w = h
j.w = h
n.x = m
n.o = h
h.w = m
d.x = j
d.o = m
assert n.o.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.o: C = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
m = C("m")
j = C("j")
n = A("n")
h = C("h")
d = A("d")

k.x = j
k.o = h
b.t = k
m.w = h
j.w = h
n.x = m
n.o = h
h.w = m
d.x = j
d.o = m
assert n.o.w.w.w.w.w.txt == "m"