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

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

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

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

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

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

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

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

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

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

m.t = l
m.s = k
j.p = l
j.w = d
j.o = e
k.x = l
k.s = l
k.p = e
d.v = a
d.p = a
d.o = c
b.x = d
b.s = d
b.p = c
l.v = m
l.p = m
l.o = j
a.t = d
a.s = g
g.x = d
g.s = d
g.p = j
e.p = d
e.w = l
e.o = j
c.p = l
c.w = l
c.o = j
assert g.p.o.o.w.txt == "d"