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

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

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

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

a = A("a")
n = B("n")
c = C("c")
d = D("d")
e = D("e")
j = C("j")
m = A("m")
h = D("h")

a.p = d
a.y = m
n.o = c
n.p = h
n.w = h
n.x = d
c.v = d
d.p = c
d.v = n
d.x = h
e.p = j
e.v = n
e.x = h
j.v = d
m.p = d
m.y = a
h.p = c
h.v = n
h.x = e
assert n.o.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.y: A = None
        self.txt = txt

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

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

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

a = A("a")
n = B("n")
c = C("c")
d = D("d")
e = D("e")
j = C("j")
m = A("m")
h = D("h")

a.p = d
a.y = m
n.o = c
n.p = h
n.w = h
n.x = d
c.v = d
d.p = c
d.v = n
d.x = h
e.p = j
e.v = n
e.x = h
j.v = d
m.p = d
m.y = a
h.p = c
h.v = n
h.x = e
assert n.o.v.p.txt == "c"