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

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

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

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

k = A("k")
m = B("m")
d = C("d")
g = D("g")
a = B("a")
c = D("c")
n = C("n")
l = A("l")
b = C("b")
e = C("e")

k.w = g
m.o = l
m.x = e
d.t = g
d.r = l
g.w = k
g.o = a
a.o = l
a.x = d
c.w = l
c.o = a
n.t = g
n.r = k
l.w = g
b.t = g
b.r = k
e.t = g
e.r = l
assert m.o.w.o.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

k = A("k")
m = B("m")
d = C("d")
g = D("g")
a = B("a")
c = D("c")
n = C("n")
l = A("l")
b = C("b")
e = C("e")

k.w = g
m.o = l
m.x = e
d.t = g
d.r = l
g.w = k
g.o = a
a.o = l
a.x = d
c.w = l
c.o = a
n.t = g
n.r = k
l.w = g
b.t = g
b.r = k
e.t = g
e.r = l
assert m.o.w.o.x.t.txt == "g"