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

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

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

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

l = A("l")
d = B("d")
f = C("f")
a = D("a")
n = C("n")
m = D("m")
j = B("j")

l.p = a
d.x = f
f.u = l
f.v = l
f.p = a
a.y = l
a.x = l
a.o = n
n.u = l
n.v = l
n.p = a
m.y = l
m.x = l
m.o = f
j.x = n
assert n.p.o.u.p.o.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

l = A("l")
d = B("d")
f = C("f")
a = D("a")
n = C("n")
m = D("m")
j = B("j")

l.p = a
d.x = f
f.u = l
f.v = l
f.p = a
a.y = l
a.x = l
a.o = n
n.u = l
n.v = l
n.p = a
m.y = l
m.x = l
m.o = f
j.x = n
assert n.p.o.u.p.o.u.p.txt == "a"