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

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

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

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

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

b.t = g
g.z = k
g.p = d
g.q = l
c.w = a
c.t = m
c.z = m
c.r = m
k.v = l
k.x = l
k.s = m
k.o = c
m.w = b
m.t = c
m.z = c
m.r = c
h.t = g
l.z = k
l.p = k
l.q = g
a.t = n
n.z = d
n.p = k
n.q = g
d.v = g
d.s = c
d.x = l
d.o = m
assert b.t.p.x.p.s.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

b.t = g
g.z = k
g.p = d
g.q = l
c.w = a
c.t = m
c.z = m
c.r = m
k.v = l
k.x = l
k.s = m
k.o = c
m.w = b
m.t = c
m.z = c
m.r = c
h.t = g
l.z = k
l.p = k
l.q = g
a.t = n
n.z = d
n.p = k
n.q = g
d.v = g
d.s = c
d.x = l
d.o = m
assert b.t.p.x.p.s.w.t.txt == "g"