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

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

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

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

f = A("f")
c = B("c")
m = C("m")
g = D("g")
l = A("l")
n = D("n")
j = D("j")
b = C("b")
i = C("i")
k = D("k")

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

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

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

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

f = A("f")
c = B("c")
m = C("m")
g = D("g")
l = A("l")
n = D("n")
j = D("j")
b = C("b")
i = C("i")
k = D("k")

f.p = c
f.y = m
c.q = n
c.v = b
c.s = g
m.y = f
m.u = n
g.s = f
g.p = f
l.p = c
l.y = m
n.s = f
n.p = f
j.s = l
j.p = f
b.y = l
b.u = g
i.y = l
i.u = j
k.s = f
k.p = f
assert n.s.y.u.s.p.q.p.p.txt == "c"