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

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

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

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

h = A("h")
k = B("k")
c = C("c")
g = D("g")
a = A("a")
b = D("b")
l = B("l")
f = C("f")

h.w = c
h.p = g
h.z = g
h.v = a
k.u = c
k.p = l
k.y = g
c.q = k
g.w = b
g.x = c
a.w = f
a.p = g
a.z = g
a.v = h
b.w = g
b.x = c
l.u = f
l.p = k
l.y = g
f.q = l
assert l.y.w.x.q.u.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: D = None
        self.z: D = None
        self.v: A = None
        self.txt = txt

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

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

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

h = A("h")
k = B("k")
c = C("c")
g = D("g")
a = A("a")
b = D("b")
l = B("l")
f = C("f")

h.w = c
h.p = g
h.z = g
h.v = a
k.u = c
k.p = l
k.y = g
c.q = k
g.w = b
g.x = c
a.w = f
a.p = g
a.z = g
a.v = h
b.w = g
b.x = c
l.u = f
l.p = k
l.y = g
f.q = l
assert l.y.w.x.q.u.q.u.q.txt == "k"