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

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: A = None
        self.q: D = None
        self.y: B = None
        self.txt = txt

j = A("j")
m = B("m")
b = C("b")
c = D("c")
h = D("h")
l = B("l")

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

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: A = None
        self.q: D = None
        self.y: B = None
        self.txt = txt

j = A("j")
m = B("m")
b = C("b")
c = D("c")
h = D("h")
l = B("l")

j.r = h
j.x = b
j.p = m
j.u = l
m.z = l
m.u = b
b.v = c
c.r = j
c.x = j
c.q = h
c.y = m
h.r = j
h.x = j
h.q = c
h.y = l
l.z = m
l.u = b
assert j.p.u.v.y.z.txt == "l"