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

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

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

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

k = A("k")
m = B("m")
l = C("l")
i = D("i")
c = D("c")
f = C("f")
j = B("j")

k.v = m
k.p = j
m.u = k
m.y = j
l.q = i
l.z = f
l.v = f
l.p = m
i.w = j
c.w = j
f.q = i
f.z = l
f.v = l
f.p = j
j.u = k
j.y = m
assert f.v.p.u.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.p: B = None
        self.txt = txt

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

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

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

k = A("k")
m = B("m")
l = C("l")
i = D("i")
c = D("c")
f = C("f")
j = B("j")

k.v = m
k.p = j
m.u = k
m.y = j
l.q = i
l.z = f
l.v = f
l.p = m
i.w = j
c.w = j
f.q = i
f.z = l
f.v = l
f.p = j
j.u = k
j.y = m
assert f.v.p.u.v.y.txt == "j"