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

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

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

g = A("g")
l = B("l")
h = C("h")
n = A("n")
j = B("j")
k = C("k")
c = C("c")

g.o = n
g.r = l
l.o = n
l.w = j
h.t = k
h.s = j
n.o = g
n.r = l
j.o = n
j.w = l
k.t = c
k.s = j
c.t = h
c.s = j
assert c.t.s.o.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: B = None
        self.txt = txt

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

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

g = A("g")
l = B("l")
h = C("h")
n = A("n")
j = B("j")
k = C("k")
c = C("c")

g.o = n
g.r = l
l.o = n
l.w = j
h.t = k
h.s = j
n.o = g
n.r = l
j.o = n
j.w = l
k.t = c
k.s = j
c.t = h
c.s = j
assert c.t.s.o.r.w.txt == "j"