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

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

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

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

a = A("a")
l = B("l")
b = C("b")
c = D("c")
d = D("d")
k = B("k")
n = C("n")
j = A("j")
i = A("i")

a.p = c
a.q = c
a.x = j
l.x = c
l.y = c
l.p = k
b.u = i
b.r = n
c.y = n
c.p = a
c.v = k
d.y = n
d.p = i
d.v = l
k.x = d
k.y = c
k.p = l
n.u = j
n.r = b
j.p = d
j.q = d
j.x = i
i.p = d
i.x = j
i.q = c
assert n.r.u.p.v.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: A = None
        self.q: D = None
        self.txt = txt

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

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

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

a = A("a")
l = B("l")
b = C("b")
c = D("c")
d = D("d")
k = B("k")
n = C("n")
j = A("j")
i = A("i")

a.p = c
a.q = c
a.x = j
l.x = c
l.y = c
l.p = k
b.u = i
b.r = n
c.y = n
c.p = a
c.v = k
d.y = n
d.p = i
d.v = l
k.x = d
k.y = c
k.p = l
n.u = j
n.r = b
j.p = d
j.q = d
j.x = i
i.p = d
i.x = j
i.q = c
assert n.r.u.p.v.p.p.p.txt == "k"