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

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

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

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

j = A("j")
d = B("d")
f = C("f")
h = D("h")
g = A("g")
i = D("i")
n = B("n")
l = C("l")
k = D("k")

j.p = l
j.u = d
j.q = f
d.q = l
f.q = g
f.y = n
h.s = g
g.p = l
g.q = l
g.u = n
i.s = j
n.q = f
l.q = g
l.y = n
k.s = g
assert i.s.p.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: B = None
        self.q: C = None
        self.txt = txt

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

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

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

j = A("j")
d = B("d")
f = C("f")
h = D("h")
g = A("g")
i = D("i")
n = B("n")
l = C("l")
k = D("k")

j.p = l
j.u = d
j.q = f
d.q = l
f.q = g
f.y = n
h.s = g
g.p = l
g.q = l
g.u = n
i.s = j
n.q = f
l.q = g
l.y = n
k.s = g
assert i.s.p.q.u.q.txt == "f"