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

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

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

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

n = A("n")
l = B("l")
f = C("f")
i = D("i")
a = B("a")
h = D("h")

n.p = f
l.x = f
l.z = f
l.w = a
f.x = l
f.r = n
f.v = n
f.o = a
i.r = n
a.x = f
a.z = f
a.w = l
h.r = n
assert i.r.p.o.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

n = A("n")
l = B("l")
f = C("f")
i = D("i")
a = B("a")
h = D("h")

n.p = f
l.x = f
l.z = f
l.w = a
f.x = l
f.r = n
f.v = n
f.o = a
i.r = n
a.x = f
a.z = f
a.w = l
h.r = n
assert i.r.p.o.w.w.txt == "a"