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

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.txt = txt

i = A("i")
n = B("n")
d = C("d")
g = D("g")
j = C("j")
k = A("k")
a = A("a")

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

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.txt = txt

i = A("i")
n = B("n")
d = C("d")
g = D("g")
j = C("j")
k = A("k")
a = A("a")

i.t = n
i.u = a
n.o = a
n.w = j
n.r = d
d.r = g
d.t = n
d.y = n
g.w = n
g.y = n
j.r = g
j.t = n
j.y = n
k.t = n
k.u = i
a.t = n
a.u = k
assert i.t.w.t.r.y.txt == "n"