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

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: B = None
        self.txt = txt

j = A("j")
m = B("m")
e = C("e")
k = D("k")
g = A("g")
b = D("b")
h = C("h")
n = C("n")

j.s = g
m.p = k
m.t = e
m.q = j
e.r = b
e.q = h
e.t = j
e.p = n
k.r = b
k.u = m
g.s = j
b.r = k
b.u = m
h.r = k
h.q = e
h.t = g
h.p = n
n.r = k
n.q = e
n.t = j
n.p = h
assert h.q.t.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: B = None
        self.txt = txt

j = A("j")
m = B("m")
e = C("e")
k = D("k")
g = A("g")
b = D("b")
h = C("h")
n = C("n")

j.s = g
m.p = k
m.t = e
m.q = j
e.r = b
e.q = h
e.t = j
e.p = n
k.r = b
k.u = m
g.s = j
b.r = k
b.u = m
h.r = k
h.q = e
h.t = g
h.p = n
n.r = k
n.q = e
n.t = j
n.p = h
assert h.q.t.s.s.s.txt == "g"