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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.z: B = None
        self.w: A = None
        self.txt = txt

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

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

c = A("c")
a = B("a")
h = C("h")
b = D("b")
e = D("e")
l = C("l")
f = D("f")
i = A("i")
j = B("j")

c.p = h
c.v = j
a.u = e
a.z = j
a.w = c
h.p = b
h.z = l
h.u = i
b.w = h
b.x = e
b.r = c
e.w = h
e.x = b
e.r = c
l.p = b
l.z = h
l.u = c
f.w = h
f.x = b
f.r = c
i.p = h
i.v = j
j.u = e
j.z = a
j.w = i
assert b.r.v.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.z: B = None
        self.w: A = None
        self.txt = txt

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

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

c = A("c")
a = B("a")
h = C("h")
b = D("b")
e = D("e")
l = C("l")
f = D("f")
i = A("i")
j = B("j")

c.p = h
c.v = j
a.u = e
a.z = j
a.w = c
h.p = b
h.z = l
h.u = i
b.w = h
b.x = e
b.r = c
e.w = h
e.x = b
e.r = c
l.p = b
l.z = h
l.u = c
f.w = h
f.x = b
f.r = c
i.p = h
i.v = j
j.u = e
j.z = a
j.w = i
assert b.r.v.z.w.txt == "c"