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

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

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

n = A("n")
a = B("a")
g = C("g")
d = C("d")
e = B("e")
j = C("j")

n.t = a
a.r = e
a.w = e
a.o = n
g.w = n
g.u = e
d.w = n
d.u = e
e.r = a
e.w = a
e.o = n
j.w = n
j.u = a
assert n.t.o.t.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

n = A("n")
a = B("a")
g = C("g")
d = C("d")
e = B("e")
j = C("j")

n.t = a
a.r = e
a.w = e
a.o = n
g.w = n
g.u = e
d.w = n
d.u = e
e.r = a
e.w = a
e.o = n
j.w = n
j.u = a
assert n.t.o.t.w.o.txt == "n"