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

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

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

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

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

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

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

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

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

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

b.s = c
b.y = g
i.y = h
i.t = d
i.q = d
c.x = m
c.s = l
c.o = g
c.z = g
h.p = m
h.t = m
h.z = b
k.y = h
k.t = d
k.q = d
m.p = h
m.t = h
m.z = g
l.y = m
l.t = d
l.q = d
d.x = m
d.s = i
d.o = b
d.z = b
a.y = h
a.t = d
a.q = c
g.s = d
g.y = b
assert l.y.z.s.s.t.s.q.txt == "d"