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

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

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

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

a = A("a")
j = B("j")
f = C("f")
c = D("c")
h = A("h")
n = B("n")

a.s = h
a.v = f
a.p = n
j.x = c
j.q = c
j.y = f
j.p = n
f.r = n
f.s = c
c.v = h
c.r = n
c.q = a
c.y = f
h.s = a
h.v = f
h.p = j
n.x = c
n.q = c
n.y = f
n.p = j
assert n.p.y.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: C = None
        self.p: B = None
        self.txt = txt

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

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

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

a = A("a")
j = B("j")
f = C("f")
c = D("c")
h = A("h")
n = B("n")

a.s = h
a.v = f
a.p = n
j.x = c
j.q = c
j.y = f
j.p = n
f.r = n
f.s = c
c.v = h
c.r = n
c.q = a
c.y = f
h.s = a
h.v = f
h.p = j
n.x = c
n.q = c
n.y = f
n.p = j
assert n.p.y.r.y.r.txt == "n"