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

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

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

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

j = A("j")
g = B("g")
f = C("f")
h = D("h")
l = B("l")

j.u = f
j.p = f
j.x = h
j.q = g
g.y = l
g.s = l
g.x = f
g.r = f
f.z = j
h.s = l
l.y = g
l.s = g
l.x = f
l.r = f
assert f.z.p.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: C = None
        self.x: D = None
        self.q: B = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
f = C("f")
h = D("h")
l = B("l")

j.u = f
j.p = f
j.x = h
j.q = g
g.y = l
g.s = l
g.x = f
g.r = f
f.z = j
h.s = l
l.y = g
l.s = g
l.x = f
l.r = f
assert f.z.p.z.u.z.txt == "j"