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

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

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

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

c = A("c")
n = B("n")
f = C("f")
m = D("m")
a = B("a")
k = C("k")
b = D("b")
i = A("i")
h = B("h")
l = D("l")

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

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

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

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

c = A("c")
n = B("n")
f = C("f")
m = D("m")
a = B("a")
k = C("k")
b = D("b")
i = A("i")
h = B("h")
l = D("l")

c.r = k
c.x = n
c.o = a
n.v = a
n.y = h
f.z = b
m.v = c
m.p = l
m.o = l
m.r = k
a.v = n
a.y = h
k.z = b
b.v = i
b.p = m
b.o = l
b.r = k
i.r = f
i.x = a
i.o = h
h.v = a
h.y = n
l.v = c
l.p = b
l.o = m
l.r = f
assert l.p.r.z.v.x.txt == "a"