class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: C = None
        self.q: B = None
        self.r: B = None
        self.txt = txt

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

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

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

i = A("i")
k = B("k")
a = C("a")
m = D("m")
h = B("h")
j = C("j")
g = D("g")
l = A("l")

i.s = h
i.p = a
i.q = k
i.r = k
k.t = g
k.s = l
k.p = h
a.v = m
a.r = m
a.o = g
m.t = l
h.t = m
h.s = i
h.p = k
j.v = g
j.o = g
j.r = m
g.t = l
l.s = h
l.r = h
l.p = j
l.q = k
assert g.t.q.s.r.t.t.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: C = None
        self.q: B = None
        self.r: B = None
        self.txt = txt

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

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

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

i = A("i")
k = B("k")
a = C("a")
m = D("m")
h = B("h")
j = C("j")
g = D("g")
l = A("l")

i.s = h
i.p = a
i.q = k
i.r = k
k.t = g
k.s = l
k.p = h
a.v = m
a.r = m
a.o = g
m.t = l
h.t = m
h.s = i
h.p = k
j.v = g
j.o = g
j.r = m
g.t = l
l.s = h
l.r = h
l.p = j
l.q = k
assert g.t.q.s.r.t.t.q.s.txt == "l"