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

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

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

k = A("k")
j = B("j")
l = C("l")
m = A("m")
a = B("a")

k.w = j
k.o = l
j.r = m
l.q = a
m.w = j
m.o = l
a.r = m
assert m.o.q.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: C = None
        self.txt = txt

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

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

k = A("k")
j = B("j")
l = C("l")
m = A("m")
a = B("a")

k.w = j
k.o = l
j.r = m
l.q = a
m.w = j
m.o = l
a.r = m
assert m.o.q.r.w.txt == "j"