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

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

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

k = A("k")
g = B("g")
j = C("j")
l = C("l")
f = B("f")
b = C("b")
h = A("h")

k.w = j
k.p = b
k.o = h
g.t = f
j.x = k
j.z = h
l.x = k
l.z = k
f.t = g
b.x = h
b.z = h
h.w = l
h.p = l
h.o = k
assert k.o.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: C = None
        self.o: A = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
j = C("j")
l = C("l")
f = B("f")
b = C("b")
h = A("h")

k.w = j
k.p = b
k.o = h
g.t = f
j.x = k
j.z = h
l.x = k
l.z = k
f.t = g
b.x = h
b.z = h
h.w = l
h.p = l
h.o = k
assert k.o.o.w.txt == "j"