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

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

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: D = None
        self.s: D = None
        self.x: D = None
        self.z: D = None
        self.txt = txt

i = A("i")
k = B("k")
m = C("m")
g = D("g")
f = B("f")
e = D("e")
l = C("l")
n = D("n")
h = B("h")

i.s = h
i.t = k
i.q = k
k.p = e
k.t = i
m.x = l
g.y = e
g.z = e
g.s = n
g.x = n
f.p = e
f.t = i
e.y = n
e.s = g
e.x = g
e.z = g
l.x = m
n.y = e
n.s = g
n.x = g
n.z = g
h.p = n
h.t = i
assert h.t.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: B = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: D = None
        self.s: D = None
        self.x: D = None
        self.z: D = None
        self.txt = txt

i = A("i")
k = B("k")
m = C("m")
g = D("g")
f = B("f")
e = D("e")
l = C("l")
n = D("n")
h = B("h")

i.s = h
i.t = k
i.q = k
k.p = e
k.t = i
m.x = l
g.y = e
g.z = e
g.s = n
g.x = n
f.p = e
f.t = i
e.y = n
e.s = g
e.x = g
e.z = g
l.x = m
n.y = e
n.s = g
n.x = g
n.z = g
h.p = n
h.t = i
assert h.t.s.p.txt == "n"